#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int q; cin >> q;
	string t[2];
	int u = 0;
	while(q--){
		int tmp; cin >> tmp;
		if(tmp == 1){
			u = 1-u;
		}else{
			int f; cin >> f; --f;
			char c; cin >> c;
			t[f ^ u].push_back(c);
		}
	}
	reverse(t[u].begin(), t[u].end());
	if(u == 1) reverse(s.begin(), s.end());
	cout << t[u] << s << t[1-u] << "\n";
}