#include using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a day,q_day; map,pll> mp; void solve(){ unordered_set ans(all(day)),new_ans; while(1> cnt(5,vector(5,0)); for(auto j:ans){ auto [p,q]=mp[{i,j}]; cnt[p][q]++; } ll mx=-INF; rep(a,5){ rep(b,5){ chmax(mx,cnt[a][b]); } } if(chmin(mn,mx)) query=i; } cout << "? " << query << '\n'; cout.flush(); ll h,b; cin >> h >> b; assert(h!=-1&&b!=-1); for(auto j:ans){ auto [p,q]=mp[{query,j}]; if(h==p&&b==q) new_ans.insert(j); } swap(ans,new_ans); new_ans.clear(); } assert(!ans.empty()); cout << "! " << *ans.begin() << '\n'; cout.flush(); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); vector d={31,29,31,30,31,30,31,31,30,31,30,31}; replr(i,1,13){ replr(j,1,d[i-1]+1){ string x=to_string(i),y=to_string(j); if(len(x)<=1) x="0"+x; if(len(y)<=1) y="0"+y; day.push_back(x+y); } } rep(i,100){ rep(j,100){ string x=to_string(i),y=to_string(j); if(len(x)<=1) x="0"+x; if(len(y)<=1) y="0"+y; set st={x[0],x[1],y[0],y[1]}; if(len(st)==4) q_day.push_back(x+y); } } for(auto s:q_day){ for(auto t:day){ ll p=0,q=0; rep(i,4){ rep(j,4){ if(s[i]==t[j]){ if(i==j) p++; else q++; } } } mp[{s,t}]={p,q}; } } ll t; cin >> t; while(t--){ solve(); } }