#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    string S;
    int Q, T, F;
    char C;
    cin >> S;
    cin >> Q;
    bool rev = false;
    deque<char> front;
    vector<char> back;
    // rep(i,Q) {
    //     cin >> T;
    //     if (T == 1) {
    //         rev = ! rev;
    //         continue;
    //     }
    //     cin >> F >> C;
    //     bool front = (F == 1) ^ rev;
    //     if (front) S = C + S;
    //     else S = S + C;
    // }
    rep(i,Q) {
        cin >> T;
        if (T == 1) {
            rev = ! rev;
            continue;
        }
        cin >> F >> C;
        bool _front = (F == 1) ^ rev;
        if (_front) front.push_front(C);
        else back.push_back(C);
    }
    if (rev) {
        reverse(S.begin(), S.end());
        reverse(front.begin(), front.end());
        reverse(back.begin(), back.end());
        for (auto ch : back) cout << ch;
        cout << S;
        for (auto ch : front) cout << ch;
    }
    else {
        for (auto ch : front) cout << ch;
        cout << S;
        for (auto ch : back) cout << ch;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 896