#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  int q; cin >> q;
  string t="";
  
  rep(i,q){
    int ty; cin >> ty;
    if(ty==1) swap(s,t);
    else{
      int f; cin >> f;
      char c; cin >> c;
      if(f==1) t+=c;
      else s+=c;
    }
  }
  reverse(t.begin(),t.end());
  t+=s;
  cout << t << endl;  
  
  return 0;
}
