S = input()
Q = int(input())

c2 = 0
query = []
for i in range(Q):
    q = [x for x in input().split()]
    T = int(q[0])
    if T == 1:
        query.append([T])
    else: # T == 2
        F, C = int(q[1]), q[2]
        query.append([T, F, C])
        c2 += 1

while len(query) > c2 + 1:
    print(query)
    T1 = query[i][0]
    if T1 == 1:
        T2 = query[i + 1][0]
        if T2 == 1:
            query = query[:i] + query[i + 2:]
        if T2 == 2:
            F, C = query[i + 1][1], query[i + 1][2]
            if F == 1:
                query[i] = [2, 2, C]
                query[i + 1] = [1]
            else: # F == 2
                query[i] = [2, 1, C]
                query[i + 1] = [1]

M = c2 + 1
for i in range(M):
    T = query[i][0]
    if T == 1:
        L = len(S)
        S = S[L - 1::-1]
    else: # T == 2
        F, C = query[i][1], query[i][2]
        if F == 1:
            S = C + S
        else: # F == 2
            S = S + C

print(S)