#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	string s;
       string ss[2];
	ll q, f=0,p=1,c=0;
	cin>>s>>q;
	while(q--){
		ll type;
		cin>>type;
		if(type==1){
			c++;
			swap(f,p);
		}
		else{
			ll x;
			char c;
			cin>>x>>c;
			if(x==1)
				ss[f].push_back(c);
			else
				ss[p].push_back(c);
		}
	}
	if(c%2)  reverse(s.begin(),s.end());

	reverse(ss[f].begin(),ss[f].end());

	cout<<ss[f]<<s<<ss[p]<<endl;
	return 0;
}
