#include <bits/stdc++.h>
using namespace std;
int main()
{
	int F,T;
	bool f=true;
	char c;
	int Q;
	string s;
	cin>>s;
	scanf("%d",&Q),getchar();
	for(int i=0;i<Q;i++){
		scanf("%d",&F),getchar();
		if(F==1) f^=1;
		else{
			scanf("%d",&T),getchar();
			scanf("%c",&c),getchar();
			if(T==1&&f==true || T==2&&f==false)
				s.insert(s.begin(),c);
			if(T==1&&f==false || T==2&&f==true)
				s.push_back(c);
		}
	}
	if(!f)reverse(s.begin(),s.end());
	cout<<s<<endl;
}