logo AlgoBeat OnlineJudge
登录 注册

#212859. [NERC 2022] Interactive Factorial Guessing

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 10 queries of the form "What is the -th decimal digit of the product of all integers from 1 to (also known as factorial and denoted as )?".

Interactive 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 of the form " " (). In response to the query, you will get a single digit --- the -th decimal digit of (the response is between 0 and 9 inclusive). Digits are numbered from 0, starting with the least significant digit. If is too short, and there is no -th digit, then 0 is returned.

After your program finds the value of it shall answer with " ". If the answer is correct, then you will receive "" 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 "". In that case, your submission will receive "" verdict and your code shall terminate immediately.

输入格式

See Interactive Protocol.

输出格式

See Interactive Protocol.

样例

样例输入 1

2

1

YES

0

2

YES

样例输出 1


? 0

! 1

? 0

? 19997

! 5982