#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

int main() {
	string s; cin >> s;
	int q; cin >> q;
	bool st = 0;
	vector<char> v[2];
	while(q--) {
		int qt; cin >> qt;
		if (qt == 1) st = !st;
		else {
			int f;
			char c;
			cin >> f >> c, f--;
			v[f^st].push_back(c);
		}
	}
	string t;
	for(int i=(int)v[0].size()-1; ~i; i--) {
		t += v[0][i];
	}
	t += s;
	for(char c : v[1]) {
		t += c;
	}
	if (st) reverse(t.begin(), t.end());
	cout << t;
}



