- Time limit: 1.00 s
- Memory limit: 512 MB
There were coders from Aalto and coders from UH in a programming contest. It turned out that after the contest, each coder had a distinct score.
Your task is to find the th highest score in the contest.
Interaction
This is a special task: you are not directly given the scores of the coders, but you can only ask a set of queries.
Your program should interact with the grader using standard input and output. Initially, the grader gives you the values of and . After this, you may perform a set of queries. There are three types of queries:
- “1 ” where : get the th highest score for Aalto
- “2 ” where : get the th highest score for UH
- “3 ”: report that the th highest score is
You are allowed to perform at most queries, and your program must terminate after performing a query of type .
Constraints
- each score is between and
Note
In some languages, you may need to flush the output after printing a line. Do not use efficient I/O methods.
Example
Assume that , and the scores for Aalto are and the scores for UH are . Here is an example of a valid interaction:
- Grader outputs:
3 1
- Your program outputs:
1 1
- Grader outputs:
9
- Your program outputs:
2 1
- Grader outputs:
8
- Your program outputs:
3 9