Interactive Factorial Guessing
Oh no, this wicked jury hides something from you again, and you need to guess it interactively.
This time, you need to find an integer . To do that, you can make at most queries of the form "What is the -th decimal digit of the product of all integers from to (also known as factorial and denoted as )?"
Interaction
Interaction Protocol In the first line, there is an integer — the number of tests you shall process. For each test, the integer is chosen in advance. The length of is at most , so . You can make at most queries of the form "? k
" . In response to the query, you will get a single digit — the -th decimal digit of (the response is between and inclusive). Digits are numbered from , starting with the least significant digit. If is too short, and there is no -th digit, then is returned.
After your program finds the value of it shall answer with "! n
". If the answer is correct, then you will receive "YES" and should proceed to the next test or terminate if it was the last one. If the answer is not correct, or you are trying to guess, and there are several possible answers consistent with the information you have received, you will get "NO". In that case, your submission will receive "Wrong answer" verdict and your code shall terminate immediately.