Sample Input

8
1 abc
3 3
2 3
1 xy
3 2
4 
4 
3 1

Sample Output

c
y
a
cases = int(raw_input())


final_ans = []
string = ''
final_ans.append(string)
for _ in range(cases):
    query = list(raw_input().split())

    if query[0]=='1':
        string = final_ans[-1]
        string += query[1]
        final_ans.append(string)
    elif query[0]=='2':
        string = final_ans[-1]
        string = list(string)
        for i in range(int(query[1])):
            temp2 = string.pop()
        string = ''.join(string)
        final_ans.append(string)
    elif query[0] == '3':
        ans = final_ans[-1]
        print(ans[int(query[1])-1])
    elif query[0] == '4':
        temp = final_ans.pop()

results matching ""

    No results matching ""