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

#define ul unsigned long long
#define ll long long

int main()
{
  string s;
  s.reserve(100000);
  ul q;
  cin>>s>>q;

  int t,f;
  int rev=0;
  string c;

  for (ul i=0;i<q;i++) {
    cin>>t;
    if (t==1) {
      rev=rev?0:1;
    }else if (t==2) {
      cin>>f>>c;
      f--;
      if (f^rev) s+=c;
      else s.insert(0,c);
    }
    //cout<<s<<endl;
  }
  if (rev)
    reverse(s.begin(), s.end());
  cout<<s<<endl;

  return 0;
}
