#include <bits/stdc++.h>
using namespace std;
int a,c,e;
char d;
string b,f;
int main()
{
	cin>>b;
	cin>>a;
	for(int i=0;i<a;i++)
	{
		cin>>c;
		if(c==1)
		e^=true;
		else
		{
			cin>>c;
			cin>>d;
			if((c==1&&e==0)||(c==2&&e==1))
			f.push_back(d);
			else
			b.push_back(d);
		}
	}
	reverse(f.begin(),f.end());
	b=f+b;
	if(e==1)
	reverse(b.begin(),b.end());
	cout<<b<<endl;
	return 0;
}