#include<stdio.h>
#include<deque>
using namespace std;
char a[100001],y[9];int q,op,x,now;deque<char>ans;
int main()
{
	scanf("%s",a);
	for(register int i=0;a[i];++i)ans.push_back(a[i]);
	for(scanf("%d",&q);q--;)
	{
		scanf("%d",&op);
		if(op==1)now^=1;
		else
		{
			scanf("%d%s",&x,y);--x;x^=now;
			if(x)ans.push_back(y[0]);
			else ans.push_front(y[0]);
		}
	}
	if(now)for(;ans.size();putchar(ans.back()),ans.pop_back());
	else for(;ans.size();putchar(ans.front()),ans.pop_front());
	putchar('\n');
}