Buggy python submission (verdict: Time Limit Exceeded):
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    han = 0
    qq=[input().split() for i in range(q)]

    for que in qq:
        if len(s) == 1 and que[0] == "1":
            continue

        if que[0] == "1":
            han += 1
            #print(han, s, que)
        else:
            if han % 2 == 0:  # 反転なし
                if que[1] == "1":
                    s = que[2]+s
                else:
                    s += que[2]
            else:  # あり
                if que[1] == "1":
                    s +=que[2]
                else:
                    s = que[2]+s
            #print(han, s, que)

    if han % 2 == 0:
        print(s)
    else:
        print(s[::-1])


if __name__ == '__main__':
    main()


Fixed submission:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    
    qq = [input().split() for i in range(q)]
    cnt=0
    r=""
    l=""
    #print(qq)
    for que in qq:
        if que[0] == "1":
            #print("a")
            r,l=l,r
            cnt+=1
            #print(r,l,cnt)
        else:
            if que[1] == "1":
                l+=que[2]
            else:
                r+=que[2]
            #print(r,l, que)
    #print(r,l)
    if cnt%2==0:
        print(l[::-1]+s+r)
    else:
        print(l[::-1]+s[::-1]+r)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    han = 0
    qq=[input().split() for i in range(q)]

    for que in qq:
        if len(s) == 1 and que[0] == "1":
            continue

        if que[0] == "1":
            han += 1
            #print(han, s, que)
        else:
            if han % 2 == 0:  # 反転なし
                if que[1] == "1":
                    s = que[2]+s
                else:
                    s += que[2]
            else:  # あり
                if que[1] == "1":
                    s +=que[2]
                else:
                    s = que[2]+s
            #print(han, s, que)

    if han % 2 == 0:
        print(s)
    else:
        print(s[::-1])


if __name__ == '__main__':
    main()


Fixed submission:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    
    qq = [input().split() for i in range(q)]
    cnt=0
    r=""
    l=""
    #print(qq)
    for que in qq:
        if que[0] == "1":
            #print("a")
            r,l=l,r
            cnt+=1
            #print(r,l,cnt)
        else:
            if que[1] == "1":
                l+=que[2]
            else:
                r+=que[2]
            #print(r,l, que)
    #print(r,l)
    if cnt%2==0:
        print(l[::-1]+s+r)
    else:
        print(l[::-1]+s[::-1]+r)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q= int(input())
    han=0
    
    for i in range(q):
        que=input().split()
        if len(s)==1 and que[0]=="1":
            continue

        if que[0]=="1":
            han+=1
            #print(han, s, que)
        else:
            if han%2==0:#反転なし
                if que[1]=="1":
                    s=que[2]+s
                else:
                    s+=que[2]
            else:#あり
                if que[1] == "1":
                    s+=que[2]
                else:
                    s=que[2]+s
            #print(han, s, que)

    if han%2==0:
        print(s)
    else:
        print(s[::-1])

if __name__ == '__main__':
    main()


Fixed submission:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    
    qq = [input().split() for i in range(q)]
    cnt=0
    r=""
    l=""
    #print(qq)
    for que in qq:
        if que[0] == "1":
            #print("a")
            r,l=l,r
            cnt+=1
            #print(r,l,cnt)
        else:
            if que[1] == "1":
                l+=que[2]
            else:
                r+=que[2]
            #print(r,l, que)
    #print(r,l)
    if cnt%2==0:
        print(l[::-1]+s+r)
    else:
        print(l[::-1]+s[::-1]+r)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q= int(input())
    han=0
    
    for i in range(q):
        que=input().split()
        if len(s)==1 and que[0]=="1":
            continue

        if que[0]=="1":
            han+=1
            #print(han, s, que)
        else:
            if han%2==0:#反転なし
                if que[1]=="1":
                    s=que[2]+s
                else:
                    s+=que[2]
            else:#あり
                if que[1] == "1":
                    s+=que[2]
                else:
                    s=que[2]+s
            #print(han, s, que)

    if han%2==0:
        print(s)
    else:
        print(s[::-1])

if __name__ == '__main__':
    main()


Fixed submission:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    
    qq = [input().split() for i in range(q)]
    cnt=0
    r=""
    l=""
    #print(qq)
    for que in qq:
        if que[0] == "1":
            #print("a")
            r,l=l,r
            cnt+=1
            #print(r,l,cnt)
        else:
            if que[1] == "1":
                l+=que[2]
            else:
                r+=que[2]
            #print(r,l, que)
    #print(r,l)
    if cnt%2==0:
        print(l[::-1]+s+r)
    else:
        print(l[::-1]+s[::-1]+r)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import sys
input = sys.stdin.readline

s = input().rstrip("\n")
q= int(input())
han=0
for i in range(q):
    que=input().split()
    if len(s)==1 and que[0]=="1":
        continue

    if que[0]=="1":
        han+=1
        #print(han, s, que)
    else:
        if han%2==0:#反転なし
            if que[1]=="1":
                s=que[2]+s
            else:
                s+=que[2]
        else:#あり
            if que[1] == "1":
                s+=que[2]
            else:
                s=que[2]+s
        #print(han, s, que)

if han%2==0:
    print(s)
else:
    print(s[::-1])


Fixed submission:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def main():
    import sys
    input = sys.stdin.readline
    s = input().rstrip("\n")
    q = int(input())
    
    qq = [input().split() for i in range(q)]
    cnt=0
    r=""
    l=""
    #print(qq)
    for que in qq:
        if que[0] == "1":
            #print("a")
            r,l=l,r
            cnt+=1
            #print(r,l,cnt)
        else:
            if que[1] == "1":
                l+=que[2]
            else:
                r+=que[2]
            #print(r,l, que)
    #print(r,l)
    if cnt%2==0:
        print(l[::-1]+s+r)
    else:
        print(l[::-1]+s[::-1]+r)



if __name__ == '__main__':
    main()