#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main() {
  string s; cin >> s;
  int q; cin >> q;
  string _s;

  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t == 1) swap(s, _s);
    else {
      int f; char c; cin >> f >> c;
      if (f == 1) _s += c;
      else s += c;
    }
  }
  reverse(_s.begin(), _s.end());
  
  cout << _s + s << endl;
  return 0;
}