#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int q;
	cin >> s >> q;

	int t, r=1;
	string fr, bc;
	for(int i=0; i<q; ++i){
		cin >> t;
		if(t==1){
			r*=-1;
			swap(fr,bc);
		}else{
			int f;
			char c;
			cin >> f >> c;
			if(f==1){
				fr+=c;
			}else{
				bc+=c;
			}
		}
	}

	reverse(fr.begin(),fr.end());
	if(r==-1) reverse(s.begin(),s.end());
	cout << fr+s+bc << endl;
}