#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<set>
#define ll long long
const int N=1e4;
const ll M=1e9;
using namespace std;

int main()
{
	string s;
	cin>>s;

		int n;
		cin>>n;
		while(n--)
		{
			int t;
			cin>>t;
			if(t==1)
				reverse(s.begin(),s.end());
			else if(t==2)
			{
				int f;
				string c;
				cin>>f>>c;
				if(f==1)
				{
					c+=s;
					s=c;
				}
				else if(f==2)
				{
					s+=c;
				}
			}		
		}
		cout<<s<<endl;
	return 0;
} 