#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(NULL);
string s,str1="",str2=""; cin>>s;
int q,k=0; cin>>q;
while(q--)
{
	int t; cin>>t;
	if(t==1)
	{
		k++;
	}
	else
	{
		int f; char ch; cin>>f>>ch;
		if(k%2)
		{
			if(f==1)
			f=2;
			else
			f=1;
		}
		if(f==1)
		{
			str1+=ch;
		}
		else
		{
			str2+=ch;
		}
	}
}
reverse(str1.begin(),str1.end());
s=str1+s+str2;
if(k%2)
reverse(s.begin(),s.end());
cout<<s;
}