// D - String Formation
#include <bits/stdc++.h>
using namespace std;

int main(){
	string S; int Q; cin>>S>>Q;
	int st = Q, ed = st + S.size(), odd = 0;
	S = string(Q,'-') + S + string(Q,'-');
	while(Q--){
		int t; cin>>t;
		if(t==1) odd ^= 1;
		else{
			int f; char c; cin>>f>>c;
			S[odd ^ (f-1)? ed++: --st] = c;
		}
	}
	string ans = "";
	if(odd) for(int i=ed-1; i>st-1; --i) ans += S[i];
	else for(int i=st; i<ed; ++i) ans += S[i];
	cout<<ans<<endl;
}