#include <iostream>
using namespace std;

int main() {
	string S;
	int Q, T, F;
	char C;
	cin >> S >> Q;
	int state = 0;
	while (Q--) {
		cin >> T;
		if (T == 1){
			state = 1 - state;
		}
		else {
			cin >> F >> C;
			if (F==1) {
				if (state==0) S.insert(S.begin(), C);
				else S.insert(S.end(), C);
			}
			else {
				if (state==1) S.insert(S.begin(), C);
				else S.insert(S.end(), C);
			}
		}
	}
	
	if (state == 1) {
		reverse(S.begin(), S.end());
		
	}
	cout << S;

}