shy19253084071 @ 2024-12-03 14:47:22
q = int(input())
s = input()
for i in range(q):
n = list(input().split())
if str(n[0]) == '1':
s = s + str(n[1])
print(s)
elif str(n[0]) == '2':
s = s[int(n[1]):int(n[1]) + int(n[2]) + 1]
print(s)
elif str(n[0]) == '3':
s = list(s)
s.insert(int(n[1]), n[2])
s = ''.join(s)
print(s)
elif str(n[0]) == '4':
s = str(s)
if str(n[1]) in str(s):
s = s.find(str(n[1]))
print(s)
else:
print(-1)