#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

#define MOD (ll)1000000007

int main() {
  string s;
  cin >> s;
  ll q;
  cin >> q;
  bool is_reverse = false;
  rep(_, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      is_reverse = !is_reverse;
    } else {
      ll f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1) {
        if (is_reverse)
          s.insert(s.end(), c);
        else
          s.insert(s.begin(), c);
      } else {
        if (is_reverse)
          s.insert(s.begin(), c);
        else
          s.insert(s.end(), c);
      }
    }
  }
  if (is_reverse)
    reverse(ALL(s));
  cout << s << endl;
}