S=eval(input())

# Python3 program to Split string into characters 

def split(word): 

    return [char for char in word]  

def convert(s): 

  

    # initialization of string to "" 

    new = "" 

  

    # traverse in the string  

    for x in s: 

        new += x  

  

    # return string  

    return new 

      

      

# Driver code 

word = S

splits=split(S)

Q=int(eval(input()))

flipcounter=0

prestring=[]

poststring=[]

for i in range(0,Q):

  inputforround=eval(input())

  if inputforround=='1':

    flipcounter=flipcounter+1

  else:

    T,F,C=list(map(str,inputforround.split()))

    if (int(F)+flipcounter)%2==1:

      prestring.append(C)

    else:

      poststring.append(C)

 

prestring.reverse()

for j in splits:

  prestring.append(j)

for k in poststring:

  prestring.append(k)

if flipcounter%2==1:

  prestring.reverse()

ans=convert(prestring)

print(ans)
S=eval(input())

# Python3 program to Split string into characters 

def split(word): 

    return [char for char in word]  

word = S

splits=split(S)

Q=int(eval(input()))

flipcounter=0

prestring=[]

poststring=[]

for i in range(0,Q):

  inputforround=eval(input())

  if inputforround=='1':

    flipcounter=flipcounter+1

  else:

    T,F,C=list(map(str,inputforround.split()))

    if (int(F)+flipcounter)%2==1:

      prestring.append(C)

    else:

      poststring.append(C)

prestring.reverse()

for j in splits:

  prestring.append(j)

for k in poststring:

  prestring.append(k)

if flipcounter%2==1:

  prestring.reverse()

ans=''.join(prestring)

print(ans)

S = eval(input())
# Python3 program to Split string into characters
def split(word):
    return [char for char in word]


def convert(s):
    # initialization of string to ""
    new = ""
    # traverse in the string
    for x in s:
        new += x
    # return string
    return new


# Driver code
word = S
splits = split(S)
Q = int(eval(input()))
flipcounter = 0
prestring = []
poststring = []
for i in range(0, Q):
    inputforround = eval(input())
    if inputforround == "1":
        flipcounter = flipcounter + 1
    else:
        T, F, C = list(map(str, inputforround.split()))
        if (int(F) + flipcounter) % 2 == 1:
            prestring.append(C)
        else:
            poststring.append(C)
prestring.reverse()
for j in splits:
    prestring.append(j)
for k in poststring:
    prestring.append(k)
if flipcounter % 2 == 1:
    prestring.reverse()
ans = convert(prestring)
print(ans)

S = eval(input())
# Python3 program to Split string into characters
def split(word):
    return [char for char in word]


word = S
splits = split(S)
Q = int(eval(input()))
flipcounter = 0
prestring = []
poststring = []
for i in range(0, Q):
    inputforround = eval(input())
    if inputforround == "1":
        flipcounter = flipcounter + 1
    else:
        T, F, C = list(map(str, inputforround.split()))
        if (int(F) + flipcounter) % 2 == 1:
            prestring.append(C)
        else:
            poststring.append(C)
prestring.reverse()
for j in splits:
    prestring.append(j)
for k in poststring:
    prestring.append(k)
if flipcounter % 2 == 1:
    prestring.reverse()
ans = "".join(prestring)
print(ans)

-def convert(s): -    # initialization of string to "" -    new = "" -    # traverse in the string -    for x in s: -        new += x -    # return string -    return new - - -# Driver code -ans = convert(prestring) +ans = "".join(prestring)