#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	string s, p[2]; int r = 0;
	cin >> s;

	int n; cin >> n; while (n--){
		int o; cin >> o;
		if (o == 1) r = !r;
		else{
			int f; string c; cin >> f >> c;
			p[(r + f) % 2] += c;
		}
	}

	reverse(p[1].begin(), p[1].end());
	s = p[1] + s + p[0];
	if (r) reverse(s.begin(), s.end());
	cout << s << endl;

	return 0;
}

