### BUGGY CODE ###

from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

s = S()
q = I()
# Q = LS(q)

# print(Q)

flag = True
for i in range(q):
    d = input().split()
    if len(d)==1:
        flag = not flag
    elif d[1]=='1':
        if flag:
            s = d[2] + s
        else:
            s = s + d[2]
    elif d[1]=='2':
        if flag:
            s = s + d[2]
        else:
            s = d[2] + s
# print(s)
if flag:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

s = input()
q = int(input())
Q = [ list(input().split()) for _ in range(q) ]

from collections import deque
s = deque(list(s))

count = 0
for i in range(q):
    t = int(Q[i][0])
    if t==1:
        count += 1
    else:
        f = int(Q[i][1])
        new = Q[i][2]
        if count%2==0 and f==1:
            s.appendleft(new)
        elif count%2==0 and f==2:
            s.append(new)
        elif count%2==1 and f==1:
            s.append(new)
        elif count%2==1 and f==2:
            s.appendleft(new)
        else:
            pass

# print(count)

if count%2==0:
    print("".join(s))
    exit()
else:
    s = list(s)[::-1]
    print("".join(s))
    exit()