#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    string s2;
    int q;
    cin >> s2 >> q;
    string s;
    int t, f;
    char c;
    rep(i, q) {
        cin >> t;
        if (t == 1) swap(s, s2);
        else {
            cin >> f >> c;
            if (f == 1) s += c;
            else s2 += c;
        }
    }
    reverse(s.begin(), s.end());
    s += s2;
    cout << s << endl;
}