#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=20005;
int n;
int ask(int x,int y)
{
cout<<"? "<<x<<" "<<y<<endl;
int r;
cin>>r;
if(r<0)exit(0);
return r;
}
void ans(int x,int y)
{
cout<<"! "<<x<<" "<<y<<endl;
int r;
cin>>r;
if(r<0)exit(0);
}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x/gcd(x,y)*y;}
bool s[N];
int res[N];
void solve()
{
cin>>n;
memset(s,1,N);
for(int i=1;i<=n;i++)
{
if(!s[i])continue;
for(int j=i+1;j<=n;j++)
{
if(!s[j])continue;
res[j]=ask(i,j);
if(res[j]*2>=n)
{
ans(i,j);
return;
}
}
int l=1;
for(int j=i+1;j<=n;j++)
{
if(!s[j])continue;
l=lcm(l,res[j]);
if(l>=n)
{
ans(i,j);
return;
}
}
for(int j=i+1;j<=n;j++)
if(res[j]<l)s[j]=0;
}
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int _;
cin>>_;
while(_--)solve();
return 0;
}