#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
  string s, c;
  string pre = "", suf = "";
  int n, t, f;
  int rc = 0;

  
  cin >> s;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
      cin >> t;
      if (t == 1) rc++;
      else {
          cin >> f >> c;
          if ((f+rc) % 2 == 1) pre = c + pre;
          else suf = suf + c;
      }
  }
  s = pre + s + suf;
  if (rc % 2 == 1) reverse(s.begin(), s.end());
  cout << s << endl;
  
  return 0;
}