#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	deque<char> que;
	string s;
	int i,q,t,f,r=0; char c;
	vector<char> str;
	vector<char> en;
	cin>>s>>q;
	for(i=0;i<s.length();i++) que.push_back(s[i]);
	while(q--)
	{
		cin>>t;
		if(t==1) r=(r+1)%2;
		else 
		{
			cin>>f>>c;
			if((f==1 && !r)|| (f==2 && r)) que.push_front(c);
			else que.push_back(c);
		}
	}
		s="";
		for(auto j:que) s.push_back(j);
		if(r){
			for(i=s.length()-1;i>-1;i--) cout<<s[i];
		}
	else cout<<s;
}