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

signed main(){
  string s,u;cin>>s;bool f=1;
  int q;cin>>q;
  while(q--){
    int t;cin>>t;
    if(t==1)f^=1;
    else{
      int a;char c;cin>>a>>c;
      if((a==1)^f)s+=c;
      else u+=c;
    }
  }
  reverse(u.begin(),u.end());
  u+=s;
  if(!f)reverse(u.begin(),u.end());
  cout<<u<<endl;
}
