This is an interactive problem.
Mettaton, the star of underworld TV show attacks you again with his pop quiz! Oh, you never played before? No problem! It's simple! There's only one rule. Answer correctly... or you lose 50% of your points in every wrong submission.
Mettaton's quiz show consists of a set of multiple choice questions. There are a total of questions, each with a total of options, numbered from 1 to and only one of them is correct, labeled . Your task is to find out ().
Ofcourse you aren't alone in this, the underground researcher Alphys is with you. Last time he got caught supplying participants with answers using hand signs, so he can't do that again. But worry not, he has devised a nice plan and installed an application in your phone.
Each time you use your the phone, you give it two integers and . Now Alphys tells you, the number of integers such that where can be written as a power of 2. More formally, and is a non-negative integer ( is the bitwise xor operation).
Since it is a live show, you don't have too much time to use the phone. You calculated that, you have just enough time to use the phone times. But you don't have to use your phone to tell the answer to Mettaton.
Read the value of ( ), which is the number of questions. Then you can start interacting.
If you want to use the phone, print ? L R
. Then you can read an integer which is what Alphys told you. You must ensure that and you haven't exceeded your asking limit (). In which case judge will give you -1 as the answer, and you must terminate your program immediately.
Once you have figured out the answer to a question, tell Mettaton like this ! h
where h is the answer you found. Then the judge outputs "OK" if your answer was correct or, "WA" otherwise. If you read "WA" you must terminate your program. If you got "OK" proceed to the interaction of your next question immediately (if there is any).
Terminate where you were told, otherwise you might get TLE or other random verdicts instead of WA.
Also remember to print newlines and flush the output after every ? L R
or ! h
operation. You can use:
fflush(stdout)
or cout.flush()
in C++System.out.flush()
in Javaflush(output)
in Pascalstdout.flush()
in PythonYou only interact with the judge. There is no other output you need to print.
Interaction Example:
Here is an example of how your program will interact with the judge. >
indicates you print something, <
indicates you take input from judge.
< 2
Mettaton has 2 questions.> ? 1 5
You use the phone.< 2
Alphys replies.> ? 3 3
You use the phone again.< 0
Alphys replies.> ! 3
You miraculously found the answer?< OK
Mettaton agrees!!!> ! 69
You answer without even asking.< OK
.....