#include <bits/stdc++.h>

using namespace std;

constexpr int MAXS = 100000, MAXQ = 200000;

char _s[MAXS + MAXQ + 2], _t[MAXQ + 2], *s = _s, *t = _t;

int main() {
	cin >> s;
	int si = strlen(s), ti = 0;
	int Q;
	cin >> Q;
	do {
		char T;
		cin >> T;
		if(T == '1') {
			swap(s, t);
			swap(si, ti);
		} else {
			char F, C;
			cin >> F >> C;
			if(F == '1') t[ti++] = C;
			else s[si++] = C;
		}
	} while(--Q);
	reverse(t, t + ti);
	cout << t << s << '\n';
}
