#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  string s;
  int n;
  cin >> s >> n;

  string t;
  
  rep(i, n) {
    int q;
    cin >> q;
    if (q == 1) {
      swap(s,t);
      continue;
    }
    int q2;
    char c;
    cin >> q2 >> c;
    if (q2 == 1) {
      t += c;
    } else {
      s += c;
    }
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
}
