Storyteller (best in the world) Şule and Glutton Efe study computer engineering at someplace that is technically a university. Since they are in their senior year, they are required to select some courses from the department's elective course offerings. Unfortunately, Efe is not as successful in computer engineering as he is in eating, and he needs the help of Şule while choosing his courses.
Şule recommends Efe to take a computer communications course and claims that every computer engineer should know how the internet and its infrastructure work. However, Efe looks for a course that is easy to get an A and he does not care about what he will learn. That's why Şule decided to create a small routing problem and convince him to take the course by asking some questions. If Efe can answer all of her questions, he will not take this course.
She assumes that,
-
There are
data sources that provide data as an integer and routers that read data from any of the data sources. Data sources are only capable of sending 1 unit of data in a unit of time. After they send data, they remove it and wait until they are requested to send another one. As in real life, each piece of data has different priorities and for this scenario, the priority is determined by the value of the data (bigger data means higher priority). -
Routers can read data from any of the data sources. However, routers have one specific responsibility. They have to read
important data among all the data waiting at the end of the data sources. For instance, the router has to return the biggest data value by looking at all data that is ready to be sent. If there exist several data streams with the same data value, the router should read data from a lower-indexed data stream.
Şule asks Efe to implement a program that responds to queries as follows.
- There are
queries to routers. - Each query contains an integer from
to that indicates the router number. - For each query to the
router, the program should print the value that is read by a router. - If there is not enough data in data streams to return the
element, the router should return the smallest element. - If
, the router should return the important data. - If there is no data in datastreams, the router should return
.
Can you help Efe to implement this program and prevent him getting low grades?
First line contains one integer
Second line contains one integer
Third line contains one integer
Following
Following
$ 1 \leq n \leq 10^4$
$ 1 \leq k \leq 10^4$
$ 1 \leq q \leq 10^4$
Print
6
3
4
3 3 6 23
2 10 5
3 7 6 1
2 8 3
3 1 2 1
1 2
1
2
2
3
10
7
6
3
Assume that there are
For
For
For
For