#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair <int, int>, null_type,less<pair <int, int>>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int MAXN = 5893, MAXM = 2e4 + 10, MOD = 998244353, MOD1 = 1e9 + 9, SQ = 350;
const long long INF = 1e9 + 11;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int fact[MAXN][MAXM];
int go[MAXM][10], tsz, query[MAXM];
vector <int> ids[MAXM];
int Build(vector <int> cand) {
int root = ++tsz;
ids[root] = cand;
if (cand.size() <= 1) return root;
int best = -1, now = cand.size() + 1;
for (int j = 0; j < MAXM; j++) {
vector <int> cnt(10, 0);
for (int i: cand) {
cnt[fact[i][j]]++;
}
int mx = 0;
for (int i = 0; i < 10; i++) {
mx = max(mx, cnt[i]);
}
if (mx < now) {
now = mx;
best = j;
}
}
query[root] = best;
vector <vector <int>> child(10, vector <int>());
for (int i: cand) {
child[fact[i][best]].pb(i);
}
for (int i = 0; i < 10; i++) {
go[root][i] = Build(child[i]);
}
return root;
}
int main() {
fact[1][0] = 1;
for (int i = 2; i < MAXN; i++) {
int carry = 0;
for (int j = 0; j < MAXM; j++) {
carry += i * fact[i - 1][j];
fact[i][j] = carry % 10;
carry /= 10;
}
}
vector <int> cand;
for (int i = 1; i < MAXN; i++) cand.pb(i);
int root = Build(cand);
int tt;
scanf("%d", &t);
while (tt--) {
int curr = root;
while (ids[curr].size() != 1){
printf("? %d\n", query[curr]);
fflush(stdout);
int cif;
scanf("%d", &cif);
curr = go[curr][cif];
}
printf("! %d\n", ids[curr][0]);
fflush(stdout);
string s;
scanf("%s", s);
}
return 0;
}