#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=50000;
ll mod=1e9+7;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

bool prime[10000001];
void fin()
{
    for(int i=2;i*i<=1000000;i++)
    {
        if(!prime[i])
        for(int j=i*i;j<=1000000;j+=i)
            prime[j]=true;
    }
}


void solve()
{
    string s,c;
    cin>>s;
    ll Q,T,F;
    cin>>Q;
    vector<pair<string,ll> > b,e;
    vector<ll> bb,ee;
    b.pb({s,-1});
    bb.pb(0);
    vector<ll> re;
    vector<pair<char,ll> > order;
    order.pb({'b',0});
    ll bi=-1,ei=-1;
    int j=-1;
    while(Q--)
    {
        cin>>T;
        j++;
        if(T==1)
        {
            re.pb(j);
        }
        else
        {
            cin>>F>>c;
            if(F==1)
            {
                b.pb({c,j});
                bb.pb(re.size());
                bi++;
                order.pb({'b',bi+1});
            }
            else
            {
                e.pb({c,j});
                ee.pb(re.size());
                ei++;
                order.pb({'e',ei});
            }
        }
    }
    //debug(re.size());
    string ans="";
    for(int i=0;i<b.size();i++)
    {
        ll temp;//=upper_bound(re.begin(),re.end(),b[i].se)-re.begin();
        temp=re.size()-bb[i];
        //debug(temp);
        if(temp%2){   string di=b[i].fi;
        reverse(di.begin(),di.end());
            b[i]={di,1};}
        else
            b[i]={b[i].fi,0};
    }
    for(int i=0;i<e.size();i++)
    {
        ll temp;//=upper_bound(re.begin(),re.end(),e[i].se)-re.begin();
        temp=re.size()-ee[i];
        if(temp%2==0){string di=e[i].fi;
        reverse(di.begin(),di.end());
            e[i]={di,1};}
        else
            e[i]={e[i].fi,0};
    }
    vector<string> endgame(400001,"");
    ll mid=200000;
    for(int i=0;i<order.size();i++)
    {
        if(order[i].fi=='b')
        {
            if(b[order[i].se].se==1)
            {
               //ans=ans+b[order[i].se].fi;
               endgame[mid+i]=b[order[i].se].fi;
            }
            else
            {
                //ans=b[order[i].se].fi+ans;
                endgame[mid-i]=b[order[i].se].fi;
            }
        }
        else
        {
            if(e[order[i].se].se==1)
            {

                endgame[mid+i]=e[order[i].se].fi;
            }
            else
            {
                //ans=
                endgame[mid-i]=e[order[i].se].fi;
            }
        }
    }
    for(int i=0;i<400001;i++)
        cout<<endgame[i];
    //reverse(ans.begin(),ans.end());
   // cout<<ans;
}

int main(){
    boost;
  solve();
}


Measured memory_bytes: 23848