Problem: This is an interactive task
William has a certain sequence of integers in his mind, but due to security concerns, he does not want to reveal it to you completely. William is ready to respond to no more than of the following questions:
- What is the result of a bitwise AND of two items with indices and ()
- What is the result of a bitwise OR of two items with indices and ()
You can ask William these questions and you need to find the -th smallest number of the sequence.
Formally the -th smallest number is equal to the number at the -th place in a 1-indexed array sorted in non-decreasing order. For example in array th smallest number is equal to , and nd and rd are .
Input Format: It is guaranteed that for each element in a sequence the condition is satisfied.
Note: In the example, the hidden sequence is .
Below is the interaction in the example.
Query (contestant's program)Response (interactor)Notesand 2 52, . Interactor returns bitwise AND of the given numbers.or 5 67, . Interactor returns bitwise OR of the given numbers.finish 5 is the correct answer. Note that you must find the value and not the index of the kth smallest number.