#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int flag = 1;
  string a;
  cin >> a;
  int n;
  cin >> n;
  vector<string> left;
  vector<string> right;
  deque<string> ret;
  ret.emplace_back(a);
  for (int i = 0; i < (n); ++i) {
    int t, f;
    string c;
    cin >> t;
    if (t == 1) {
      flag *= -1;
      continue;
    }
    cin >> f >> c;
    if (f == 2) f = -1;
    if (flag == 1) {
      if (f == 1)
        ret.push_front(c);
      else
        ret.emplace_back(c);
    } else {
      if (f == 1)
        ret.emplace_back(c);
      else
        ret.push_front(c);
    }
  }
  if (flag == 1) {
    for (int i = 0; i < (ret.size()); i++) {
      cout << ret[i];
    }
    cout << endl;
  } else {
    for (int i = (ret.size()) - 1; i >= 0; i--) {
      if (ret[i].size() > 0) reverse(ret[i].begin(), ret[i].end());
      cout << ret[i];
    }
    cout << endl;
  }
  return 0;
}
