q = int(input()) st = input() for _ in range(q): g = input().strip().split() t = int(g[0]) if t == 1: st += g[1] print(st) if t == 2: a, b = int(g[1]),int(g[2]) st = st[a:a+b] print(st) if t==3: a, b = int(g[1]), g[2] st = st[0:a]+b+st[a:] print(st) if t==4: print(st.find(g[1]))