#include <bits/stdc++.h>
using namespace std;
int main(){
	string S,T;
	int Q;
	cin>>S>>Q;
	while(Q--){
		int type;
		cin>>type;
		if(type==1)
			swap(S,T);
		else{
			int f;
			char c;
			cin>>f>>c;
			if(f==1)
				T.push_back(c);
			else
        		S.push_back(c);
		}
	}
	reverse(T.begin(),T.end());
	cout<<T+S<<endl;
	return 0;
}