#include <bits/stdc++.h>
using namespace std;

int main()
{
	string s,sf,sb,tp;
	cin>>s;
	int q,t,f;bool rev=false;
	cin>>q;char c;
	deque <char> dq(s.begin(),s.end());
	while(q--)
	{
		cin>>t;
		if(t==1)rev=!rev;
		else
		{
			cin>>f>>c;
			if((f==1&&!rev)||(f==2&&rev))
			{
				dq.push_front(c);
			}
			else
			{
				dq.push_back(c);
			}
		}
	}
	if(rev)
	for(auto it=dq.rbegin();it!=dq.rend();it++)cout<<*it;
	else
	for(auto it=dq.begin();it!=dq.end();it++)cout<<*it;
}