Which k-th are you?
Kozak Vus possesses three secret arrays , , and , each containing positive integers. The lengths of these arrays are , , and , respectively, and they may differ from one another. Each array is sorted in non-decreasing order.
Your task is to determine the -th smallest element in the sorted union of these arrays. This means you need to merge the three arrays into a single array of length , sort it, and identify the -th element.
Kozak Vus will not reveal the arrays directly, but he allows you to query specific elements. You can select an array and a position within that array, and Kozak Vus will provide the value at that position. You can perform this operation multiple times, across any of the arrays, but you are limited to a maximum of queries.
Your goal is to find the -th smallest element in the combined sorted array.
Input
The first line contains five integers: , , , , and (, ).
All numbers in the arrays are guaranteed to be within the range .
The integer () indicates the test group number (refer to Scoring).
Interaction
First, read the five integers , , , , and .
To make a query, output "1 ", where specifies the array (1 for , 2 for , 3 for ), and is the position within that array. For example, querying the first element of array requires , and querying the last element requires .
An example query "1 3 10" requests the 10th element of array .
After issuing a query, ensure you output a newline character and flush the output buffer to avoid a Time Limit Exceeded
verdict. Use the following commands to flush the buffer:
fflush(stdout)
orcout.flush()
in C++;System.out.flush()
in Java;flush(output)
in Pascal;stdout.flush()
in Python;
Refer to the documentation for other languages.
If a query is invalid (exceeding the query limit or not meeting constraints), the interactor will return "-1" and terminate. If you receive "-1", immediately terminate your program to avoid an arbitrary verdict and receive a Wrong Answer
verdict instead.
Once you determine the answer , output "2 ".
Examples
3 3 3 2 0 2 5 5 2 6 6 6 7 10
1 1 1 1 1 2 1 1 3 1 2 1 1 2 2 1 2 3 1 3 1 1 3 2 1 3 3 2 2
Scoring
Let , and .
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): .