Problem: cf1999_g1
Difficulty: medium
Categories: search, math
Time limit: 1000 ms, memory limit: 256 MB

This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most $\mathbf{10}$ queries.

This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.

We have a secret ruler that is missing one number $x$ ($2 \leq x \leq 999$). When you measure an object of length $y$, the ruler reports the following values:

* If $y < x$, the ruler (correctly) measures the object as having length $y$.
* If $y \geq x$, the ruler incorrectly measures the object as having length $y+1$.![](https://espresso.codeforces.com/a98908c8e65eba44622cf7a3ee2ee84099990643.png)

The ruler above is missing the number $4$, so it correctly measures the first segment as length $3$ but incorrectly measures the second segment as length $6$ even though it is actually $5$.

You need to find the value of $x$. To do that, you can make queries of the following form:

* $\texttt{?}~a~b$ — in response, we will measure the side lengths of an $a \times b$ rectangle with our ruler and multiply the results, reporting the measured area of the rectangle back to you. For example, if $x=4$ and you query a $3 \times 5$ rectangle, we will measure its side lengths as $3 \times 6$ and report $18$ back to you.

Find the value of $x$. You can ask at most $\mathbf{10}$ queries.

Input

Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \leq t \leq 1000$) — the number of test cases.

Interaction

There is no initial input for each test case. You should begin the interaction by asking a query.

To make a query, output a single line of the form $\texttt{?}~a~b$ ($1 \leq a, b \leq 1000$). In response, you will be told the measured area of the rectangle, according to our secret ruler.

When you are ready to print the answer, output a single line of the form $\texttt{!}~x$ ($2 \leq x \leq 999$). After that, proceed to process the next test case or terminate the program if it was the last test case. Printing the answer does not count as a query.

The interactor is not adaptive, meaning that the answer is known before the participant asks the queries and doesn't depend on the queries asked by the participant.

If your program makes more than $10$ queries for one set of input data, makes an invalid query, or prints the wrong value of $x$, then the response to the query will be $-1$. After receiving such a response, your program should immediately terminate to receive the verdict Wrong Answer. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

After printing a query do not forget to output the end of line and flush the output. Otherwise, you may get Idleness limit exceeded verdict. To do this, use:

* fflush(stdout) or cout.flush() in C++;
* System.out.flush() in Java;
* flush(output) in Pascal;
* stdout.flush() in Python;
* see the documentation for other languages.

Example

Input

```
2

18

25

9999
```

Output

```? 3 5? 4 4! 4? 99 100! 100
```

Note

In the first test, the interaction proceeds as follows.

|  |  |  |
| --- | --- | --- |
| Solution | Jury | Explanation |
|  | $\texttt{2}$ | There are 2 test cases. |
| $\texttt{? 3 5}$ | $\texttt{18}$ | Secretly, the jury picked $x=4$. The solution requests the $3 \times 5$ rectangle, and the jury responds with $3 \times 6 = 18$, as described in the statement. |
| $\texttt{? 4 4}$ | $\texttt{25}$ | The solution requests the $4 \times 4$ rectangle, which the jury measures as $5 \times 5$ and responds with $25$. |
| $\texttt{! 4}$ |  | The solution has somehow determined that $x=4$, and outputs it. Since the output is correct, the jury continues to the next test case. |
| $\texttt{? 99 100}$ | $\texttt{1}$ | Secretly, the jury picked $x=100$. The solution requests the $99 \times 100$ rectangle, which the jury measures as $99 \times 101$ and responds with $9999$. |
| $\texttt{! 100}$ |  | The solution has somehow determined that $x=100$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit. |

Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

Non-adaptive interactor (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;


static long long max_queries_used = 0;

static const long long query_limit = 10;

static const long long HARD_CAP = 200000;



static void log_metrics() {
    try {
        tout << "queries=" << max_queries_used << endl;
        tout << "query_limit=" << query_limit << endl;
    } catch (...) {
        
    }
}


static void finish(TResult verdict, const string& msg) {
    log_metrics();
    quitf(verdict, "%s", msg.c_str());
}




static long long measure(long long val, int x) {
    if (val < x) return val;
    return val + 1;
}

int main(int argc, char** argv) {
    
    registerInteraction(argc, argv);

    
    atexit(log_metrics);

    
    int t = inf.readInt();
    
    
    cout << t << endl;

    
    log_metrics();

    long long total_ops = 0;

    for (int i = 0; i < t; i++) {
        
        int x = inf.readInt();
        int current_case_queries = 0;
        bool case_solved = false;

        while (!case_solved) {
            
            if (total_ops > HARD_CAP) {
                finish(_pe, "Hard cap on interactions exceeded.");
            }
            total_ops++;

            
            string token;
            if (!(cin >> token)) {
                finish(_wa, "Unexpected end of file from solution.");
            }

            if (token == "!") {
                
                int guess;
                if (!(cin >> guess)) {
                    finish(_wa, "Failed to read answer value.");
                }

                if (guess != x) {
                    finish(_wa, format("Wrong answer on test case %d. Expected %d, found %d.", i + 1, x, guess));
                } else {
                    
                    case_solved = true;
                }
            } else {
                
                int a, b;
                
                
                if (token == "?") {
                    if (!(cin >> a >> b)) {
                        finish(_wa, "Failed to read query arguments.");
                    }
                } else {
                    
                    try {
                        size_t idx;
                        a = stoi(token, &idx);
                        if (idx != token.size()) throw exception();
                    } catch (...) {
                        finish(_wa, "Invalid token received: " + token);
                    }
                    if (!(cin >> b)) {
                        finish(_wa, "Failed to read second query argument.");
                    }
                }

                
                if (a < 1 || a > 1000 || b < 1 || b > 1000) {
                    finish(_wa, format("Query arguments out of range [1, 1000]: %d %d", a, b));
                }

                
                current_case_queries++;
                if (current_case_queries > max_queries_used) {
                    max_queries_used = current_case_queries;
                    
                    log_metrics();
                }

                
                
                long long val_a = measure(a, x);
                long long val_b = measure(b, x);
                long long area = val_a * val_b;

                cout << area << endl;
            }
        }
    }

    finish(_ok, "All test cases passed.");
    return 0;
}


Adaptive interactor (C++):

Test generator (C++):
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char* argv[]) {
    registerGen(argc, argv, 1);

    
    
    string mode = opt<string>("mode", "non");
    
    int t = opt<int>("t", 100);

    
    if (t < 1) t = 1;
    if (t > 1000) t = 1000;

    
    cout << t << endl;

    if (mode == "adp") {
        
        
        for (int i = 0; i < t; i++) {
            cout << "2 999" << endl;
        }
    } else {
        
        vector<int> cases;

        if (t >= 998) {
            
            for (int x = 2; x <= 999; x++) {
                cases.push_back(x);
            }
            
            while ((int)cases.size() < t) {
                cases.push_back(rnd.next(2, 999));
            }
        } else {
            
            cases.push_back(2);
            cases.push_back(999);
            
            
            int specials[] = {3, 9, 27, 81, 243, 729};
            for (int val : specials) {
                if (val >= 2 && val <= 999) {
                    cases.push_back(val);
                }
            }
            
            
            while ((int)cases.size() < t) {
                cases.push_back(rnd.next(2, 999));
            }
        }

        
        shuffle(cases.begin(), cases.end());

        
        if ((int)cases.size() > t) {
            cases.resize(t);
        }

        
        for (int x : cases) {
            cout << x << endl;
        }
    }

    return 0;
}