#include <bits/stdc++.h>
using namespace std;
const long long MOD = long long(1e9 + 7);
const long long INF = long long(1e18) + 7;
long long P_POW(long long i, long long n) {
  if (n == 0) return 1;
  n--;
  long long rep = i;
  while (n) {
    rep = rep * i;
    n--;
  }
  return rep;
}
unsigned GetDigit(unsigned num) {
  unsigned digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}
unsigned binarySearch(long long target, long long max, long long min) {
  while ((max - min) > 1) {
    if ((max + min) / 2 > target) {
      max = (max + min) / 2;
      min = min;
    } else {
      max = max;
      min = (max + min) / 2;
    }
  }
}
void f(int rest, string s) {
  char abc[] = "abc";
  if (rest == 0) {
    cout << s << endl;
  } else {
    for (int i = 0; i < 3; i++) {
      f(rest - 1, s + abc[i]);
    }
  }
}
int main() {
  string a;
  long long q;
  cin >> a;
  cin >> q;
  string ac = a;
  string ad = a;
  string ae = a;
  long long t;
  long long f;
  string c;
  for (long long i = 0; i < q; i++) {
    cin >> t;
    if (t == 2) {
      cin >> f;
      cin >> c;
      if (f == 1) {
        ad = ad + c;
        ac = c + ac;
      } else {
        ad = c + ad;
        ac = ac + c;
      }
    } else {
      ae = ad;
      ad = ac;
      ac = ae;
    }
  }
  cout << ac;
}
