Server Time: Sun Aug 9, 2020 6:25 am
 Welcome ( logout )
1087 - Diablo
 PDF (English) Statistics Forum
 Time Limit: 2 second(s) Memory Limit: 64 MB

All of you must have played the game 'Diablo'. It's an exclusive game to play. In this game the main opponent of you is Diablo. If you kill him the game finishes. But as usual, Diablo is smarter than you.

Diablo has a large number of army. Diablo arranges them in a line in any arbitrary order and everyone is given an integer id. Each time Diablo either adds one army in the end or he calls for the kth army (from left) from the line. Then the army gets out and it attacks you.

Since you are a great magician, you can read Diablo's mind. Now you want to find the id of the armies who are about to attack you.

# Input

Input starts with an integer T (≤ 5), denoting the number of test cases.

The first line of each case is a blank line. The next line contains two integers n (0 ≤ n ≤ 105), denoting the number of the initial army and q (1 ≤ q ≤ 50000) representing the number of queries. The next line contains n space separated integers. The ith integer of this line denotes the id of the ith person. Each of these integers will be positive and fits into a 32 bit signed integer. Each of the next q lines will contain a query, of the form:

a p    (add a person at the end of the line whose id is p)

c k    (call the kth person from the line (from left), k is a positive 32 bit signed integer)

# Output

For each case of input, print the case number in a line. Then for all the queries 'c k' you have to print the id of the kth person or 'none' if there is none.

2

5 5

6 5 3 2 1

c 1

c 1

a 20

c 4

c 4

2 1

18811 1991

c 1

Case 1:

6

5

20

none

Case 2:

18811

# Notes

Dataset is huge, use faster i/o methods.

Problem Setter: Jane Alam Jan
 Developed and Maintained by JANE ALAM JAN Copyright © 2012 LightOJ, Jane Alam Jan