alph="abcdefghijklmnopqrstuvwxyz"

from collections import deque

import sys

input=sys.stdin.readline

moji=deque([])

s=input().rstrip()

for i in range(len(s)):

	for j in range(26):

		if s[i]==alph[j]:

			moji.append(j)

			break

q=int(eval(input()))

rev=0

for _ in range(q):

	qw=input().split()

	if qw[0]=="1":

		rev+=1

	else:

		f=qw[1]

		c=qw[2]

		for j in range(26):

			if c==alph[j]:

				x=j

				break

		if f=="1":

			if rev%2==0:

				moji.appendleft(x)

			else:

				moji.append(x)

		else:

			if rev%2==0:

				moji.append(x)

			else:

				moji.appendleft(x)

ans=""

r=[]

for i in range(len(moji)):

	r.append(moji.popleft())

for i in range(len(r)):

	ans+=alph[r[i]]

if rev%2==0:

	print(ans)

else:

	print((ans[::-1]))

from collections import deque

import sys

input=sys.stdin.readline

s=deque([input().rstrip()])

q=int(eval(input()))

rev=0

for _ in range(q):

	qw=input().split()

	if qw[0]=="1":

		rev+=1

	else:

		f=qw[1]

		c=qw[2]

		if f=="1":

			if rev%2==0:

				s.appendleft(c)

			else:

				s.append(c)

		else:

			if rev%2==0:

				s.append(c)

			else:

				s.appendleft(c)

ans=""

for x in s:

	ans+=x

if rev%2==0:

	print(ans)

else:

	print((ans[::-1]))



alph = "abcdefghijklmnopqrstuvwxyz"
from collections import deque
import sys

input = sys.stdin.readline
moji = deque([])
s = input().rstrip()
for i in range(len(s)):
    for j in range(26):
        if s[i] == alph[j]:
            moji.append(j)
            break
q = int(eval(input()))
rev = 0
for _ in range(q):
    qw = input().split()
    if qw[0] == "1":
        rev += 1
    else:
        f = qw[1]
        c = qw[2]
        for j in range(26):
            if c == alph[j]:
                x = j
                break
        if f == "1":
            if rev % 2 == 0:
                moji.appendleft(x)
            else:
                moji.append(x)
        else:
            if rev % 2 == 0:
                moji.append(x)
            else:
                moji.appendleft(x)
ans = ""
r = []
for i in range(len(moji)):
    r.append(moji.popleft())
for i in range(len(r)):
    ans += alph[r[i]]
if rev % 2 == 0:
    print(ans)
else:
    print((ans[::-1]))

from collections import deque
import sys

input = sys.stdin.readline
s = deque([input().rstrip()])
q = int(eval(input()))
rev = 0
for _ in range(q):
    qw = input().split()
    if qw[0] == "1":
        rev += 1
    else:
        f = qw[1]
        c = qw[2]
        if f == "1":
            if rev % 2 == 0:
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if rev % 2 == 0:
                s.append(c)
            else:
                s.appendleft(c)
ans = ""
for x in s:
    ans += x
if rev % 2 == 0:
    print(ans)
else:
    print((ans[::-1]))

-alph = "abcdefghijklmnopqrstuvwxyz" -moji = deque([]) -s = input().rstrip() -for i in range(len(s)): -    for j in range(26): -        if s[i] == alph[j]: -            moji.append(j) -            break +s = deque([input().rstrip()]) -        for j in range(26): -            if c == alph[j]: -                x = j -                break -                moji.appendleft(x) +                s.appendleft(c) -                moji.append(x) +                s.append(c) -                moji.append(x) +                s.append(c) -                moji.appendleft(x) +                s.appendleft(c) -r = [] -for i in range(len(moji)): -    r.append(moji.popleft()) -for i in range(len(r)): -    ans += alph[r[i]] +for x in s: +    ans += x