Buggy python submission (verdict: Time Limit Exceeded):
def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s = qu[2] + s
				else:
					s = s + qu[2]
			else:
				if qu[1] == '2':
					s = qu[2] + s
				else:
					s = s + qu[2]
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(s)
	else:
		print(s[::-1])

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	from collections import deque
	s = deque(s)
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
			else:
				if qu[1] == '2':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(''.join(map(str,s)))
	else:
		s.reverse()
		print(''.join(map(str,s)))

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	s = str(input())
	q = int(input())
	qu = [list(map(str,input().split())) for x in range(q)]
	shiji = 1
	rcount = 0
	for i in range(q):
		if qu[i][0] != '1':
			if shiji == 1:
				if qu[i][1] == '1':
					s = qu[i][2] + s
				else:
					s = s + qu[i][2]
			else:
				if qu[i][1] == '2':
					s = qu[i][2] + s
				else:
					s = s + qu[i][2]
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(s)
	else:
		print(s[::-1])

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	from collections import deque
	s = deque(s)
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
			else:
				if qu[1] == '2':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(''.join(map(str,s)))
	else:
		s.reverse()
		print(''.join(map(str,s)))

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	s = str(input())
	q = int(input())
	qu = [list(map(str,input().split())) for x in range(q)]
	shiji = 1
	rcount = 0
	for i in range(q):
		if qu[i][0] != '1':
			if shiji == 1:
				if qu[i][1] == '1':
					s = qu[i][2] + s
				else:
					s = s + qu[i][2]
			else:
				if qu[i][1] == '2':
					s = qu[i][2] + s
				else:
					s = s + qu[i][2]
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(s)
	else:
		s = list(s)
		s.reverse()
		print(''.join(map(str,s)))

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	from collections import deque
	s = deque(s)
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
			else:
				if qu[1] == '2':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(''.join(map(str,s)))
	else:
		s.reverse()
		print(''.join(map(str,s)))

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	s = list(str(input()))
	q = int(input())
	qu = [list(map(str,input().split())) for x in range(q)]

	for i in range(q):
		if qu[i][0] != '1':
			if qu[i][1] == '1':
				s.insert(0,qu[i][2])
			else:
				s.append(qu[i][2])
		else:
			s.reverse()

	print(''.join(map(str,s)))

if __name__ == '__main__':
	main()

Fixed submission:
def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	from collections import deque
	s = deque(s)
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
			else:
				if qu[1] == '2':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(''.join(map(str,s)))
	else:
		s.reverse()
		print(''.join(map(str,s)))

if __name__ == '__main__':
	main()