import sys

# import math

# import decimal

# import queue

# import bisect

# import heapq

# import time

# import itertools

import collections

# from fractions import Fraction



mod = int(1e9+7)

INF = 1<<29



def main():

    s = collections.deque(list(eval(input())))

    q = int(eval(input()))

    count = 0

    for i in range(q):

        tfc = list(input().split())

        if tfc[0]=='1':

            count = abs(count - 1)

        else:

            t,f,c = tfc

            if count:

                if f=='1':

                    s.append(c)

                else:

                    s.appendleft(c)

            else:

                if f=='1':

                    s.appendleft(c)

                else:

                    s.append(c)

    if count:

        t = []

        for i in range(len(s)):

            t.append(s.pop())

        print((''.join(t)))

    else:

        print((''.join(s)))

    return



if __name__=='__main__':

    main()

import collections



s = collections.deque(list(eval(input())))

q = int(eval(input()))

rev = 0

for i in range(q):

    tfc = list(input().split())

    if tfc[0]=='1':

        rev = abs(rev-1)

    else:

        t,f,c = tfc

        if rev:

            if f=='1':

                s.append(c)

            else:

                s.appendleft(c)

        else:

            if f=='1':

                s.appendleft(c)

            else:

                s.append(c)

if rev:

    t = []

    for i in range(len(s)):

        t.append(s.pop())

    print((''.join(t)))

else:

    print((''.join(s)))
import sys

# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
import collections

# from fractions import Fraction
mod = int(1e9 + 7)
INF = 1 << 29


def main():
    s = collections.deque(list(eval(input())))
    q = int(eval(input()))
    count = 0
    for i in range(q):
        tfc = list(input().split())
        if tfc[0] == "1":
            count = abs(count - 1)
        else:
            t, f, c = tfc
            if count:
                if f == "1":
                    s.append(c)
                else:
                    s.appendleft(c)
            else:
                if f == "1":
                    s.appendleft(c)
                else:
                    s.append(c)
    if count:
        t = []
        for i in range(len(s)):
            t.append(s.pop())
        print(("".join(t)))
    else:
        print(("".join(s)))
    return


if __name__ == "__main__":
    main()

import collections

s = collections.deque(list(eval(input())))
q = int(eval(input()))
rev = 0
for i in range(q):
    tfc = list(input().split())
    if tfc[0] == "1":
        rev = abs(rev - 1)
    else:
        t, f, c = tfc
        if rev:
            if f == "1":
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if f == "1":
                s.appendleft(c)
            else:
                s.append(c)
if rev:
    t = []
    for i in range(len(s)):
        t.append(s.pop())
    print(("".join(t)))
else:
    print(("".join(s)))

-import sys - -# import math -# import decimal -# import queue -# import bisect -# import heapq -# import time -# import itertools -# from fractions import Fraction -mod = int(1e9 + 7) -INF = 1 << 29 - - -def main(): -    s = collections.deque(list(eval(input()))) -    q = int(eval(input())) -    count = 0 -    for i in range(q): -        tfc = list(input().split()) -        if tfc[0] == "1": -            count = abs(count - 1) +s = collections.deque(list(eval(input()))) +q = int(eval(input())) +rev = 0 +for i in range(q): +    tfc = list(input().split()) +    if tfc[0] == "1": +        rev = abs(rev - 1) +    else: +        t, f, c = tfc +        if rev: +            if f == "1": +                s.append(c) +            else: +                s.appendleft(c) -            t, f, c = tfc -            if count: -                if f == "1": -                    s.append(c) -                else: -                    s.appendleft(c) +            if f == "1": +                s.appendleft(c) -                if f == "1": -                    s.appendleft(c) -                else: -                    s.append(c) -    if count: -        t = [] -        for i in range(len(s)): -            t.append(s.pop()) -        print(("".join(t))) -    else: -        print(("".join(s))) -    return - - -if __name__ == "__main__": -    main() +                s.append(c) +if rev: +    t = [] +    for i in range(len(s)): +        t.append(s.pop()) +    print(("".join(t))) +else: +    print(("".join(s)))