from collections import deque



S = eval(input())

Q = int(eval(input()))

S = deque(S)



cnt_reverse = 0



for q in range(Q):

  _ = eval(input())

  if _[0] == '1':

    cnt_reverse += 1

  else:

    _T, _F, _C = _.split()

    ## リバース回数が奇数偶数のいずれかをチェック

    if _F == '1':

      if cnt_reverse % 2 == 0:

        S.appendleft(_C)

      else:

        S.append(_C)

    else:

      if cnt_reverse % 2 == 0:

        S.append(_C)

      else:

        S.appendleft(_C)



S = list(S)

# reverseの部分を対応

if cnt_reverse % 2 == 1:

  S.reverse()



print((''.join(S)))
from collections import deque

 

S = eval(input())

Q = int(eval(input()))

S = deque(S)

 

flg_reverse = False

 

for q in range(Q):

  _ = eval(input())

  if _[0] == '1':

    flg_reverse = flg_reverse ^ True

  else:

    _T, _F, _C = _.split()

    ## リバース回数が奇数偶数のいずれかをチェック

    if _F == '1':

      if flg_reverse:

        S.append(_C)

      else:

        S.appendleft(_C)

    else:

      if flg_reverse:

        S.appendleft(_C)

      else:

        S.append(_C)        

 

S = list(S)

# reverseの部分を対応

if flg_reverse:

  S.reverse()

 

print((''.join(S)))
from collections import deque

S = eval(input())
Q = int(eval(input()))
S = deque(S)
cnt_reverse = 0
for q in range(Q):
    _ = eval(input())
    if _[0] == "1":
        cnt_reverse += 1
    else:
        _T, _F, _C = _.split()
        ## リバース回数が奇数偶数のいずれかをチェック
        if _F == "1":
            if cnt_reverse % 2 == 0:
                S.appendleft(_C)
            else:
                S.append(_C)
        else:
            if cnt_reverse % 2 == 0:
                S.append(_C)
            else:
                S.appendleft(_C)
S = list(S)
# reverseの部分を対応
if cnt_reverse % 2 == 1:
    S.reverse()
print(("".join(S)))

from collections import deque

S = eval(input())
Q = int(eval(input()))
S = deque(S)
flg_reverse = False
for q in range(Q):
    _ = eval(input())
    if _[0] == "1":
        flg_reverse = flg_reverse ^ True
    else:
        _T, _F, _C = _.split()
        ## リバース回数が奇数偶数のいずれかをチェック
        if _F == "1":
            if flg_reverse:
                S.append(_C)
            else:
                S.appendleft(_C)
        else:
            if flg_reverse:
                S.appendleft(_C)
            else:
                S.append(_C)
S = list(S)
# reverseの部分を対応
if flg_reverse:
    S.reverse()
print(("".join(S)))

-cnt_reverse = 0 +flg_reverse = False -        cnt_reverse += 1 +        flg_reverse = flg_reverse ^ True -            if cnt_reverse % 2 == 0: +            if flg_reverse: +                S.append(_C) +            else: +                S.appendleft(_C) +        else: +            if flg_reverse: -        else: -            if cnt_reverse % 2 == 0: -                S.append(_C) -            else: -                S.appendleft(_C) -if cnt_reverse % 2 == 1: +if flg_reverse: