#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s;
	char c;
	int q;
	int t, f;
	
	cin >> s;
	cin >> q;
	
	for(int i = 1; i <= q; i++)
	{
		cin >> t;
		if(t == 1)
		{
			string tmp = s;
			for(int j = 0; j < s.size(); j++)
			{
				s[j] = tmp[s.size()-1-j];
			}
		}
		if(t == 2)
		{
			cin >> f;
			if(f == 1)
			{
				cin >> c;
				s.insert(s.begin(), c);
			}
			if(f == 2)
			{
				cin >> c;
				s.push_back(c);
			}
		}
	}
	cout << s << endl;
	
	return 0;
}