#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mid ((l+r)>>1)
#define mod (998244353)
// #define mod (1000000007)
#define ull unsigned long long
#define eps (1e-8)
#define mk make_pair
#define tim (double)clock()/CLOCKS_PER_SEC
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,a,b) for(int i=(a);i>=(b);--i)
inline namespace IO{
inline int read(){
int x=0,f=1;char ch;
while((ch=getchar())<'0'||x>'9')if(ch=='-')f=-1;
while(ch>='0'&&ch<='9'){x=((x<<1)+(x<<3)+(ch^48)),ch=getchar();}
return x*f;
}
void write(char x){putchar(x);}
void write(const char *x){for(;*x;++x)putchar(*x);}
void write(char *x){for(;*x;++x)putchar(*x);}
void write(signed x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10); putchar('0'+x-x/10*10);
}
void write(long long x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10); putchar('0'+x-x/10*10);
}
void write(unsigned long long x){
if(x>9)write(x/10);
putchar('0'+x-x/10*10);
}
void write(double x){printf("%0.5lf",x);}
template<typename type1,typename type2,typename ...typen>
void write(type1 a1,type2 a2,typen ...an){
write(a1);
write(a2,an...);
}
}using namespace IO;
inline int gcd(int x,int y){return y==0?x:gcd(y,x%y);}
inline int lcm(int x,int y){return x/gcd(x,y)*y;}
inline int lowbit(int x){return x&(-x);}
const int N=1900005;
inline int qpow(int a,int b){
int res=1;
for(;b;b>>=1){
if(b&1)res=res*a%mod;
a=a*a%mod;
}return res;
}
int n;
inline void work(){
cin>>n;
for(int i=1;i+1<=n;i+=2){
cout<<"? "<<i<<' '<<i+1<<endl;
int x; cin>>x;
if(x==1){
int pos=0;
for(int j=1;j<=n;j++){
if(i+1==j||i==j)continue;
pos=j;
cout<<"? "<<i<<' '<<j<<endl;
cin>>x;
break;
}
if(x==0){
int cnt=0;
for(int j=1;j<=n;j++){
if(i+1==j||i==j)continue;
cnt++;
cout<<"? "<<i+1<<' '<<j<<endl;
cin>>x;
if(x==0){
cout<<"! 1"<<endl;
return;
}
if(cnt>=2)break;
}
cout<<"! 2"<<endl;
return;
}else{
for(int j=1;j<=n;j++){
if(i+1==j||i==j)continue;
cout<<"? "<<i+1<<' '<<j<<endl;
cin>>x;
if(x==1){
cout<<"! 1"<<endl;
return;
}
break;
}
for(int j=pos+1;j<=n;j++){
iif(i+1==j||i==j)continue;
cout<<"? "<<i<<' '<<j<<endl;
cin>>x;
if(x==1){
cout<<"! 2"<<endl;
return;
}else {
cout<<"! 1"<<endl;
return;
}
}
}
return;
}
}
if(n&1){
int x;
cout<<"? "<<1<<' '<<n<<endl;
cin>>x;
if(!x){
cout<<"! 1"<<endl;
return;
}
cout<<"? "<<2<<' '<<n<<endl;
cin>>x;
if(!x){
cout<<"! 1"<<endl;
return;
}
cout<<"! 2"<<endl;
}else{
cout<<"! 1"<<endl;
}
}
signed main()
{
// freopen("data.in","r",stdin);
// freopen("std1.out","w",stdout);
int T=read();
For(i,1,T)work();
return 0;
}
/*
1 0
*/