//####################
//Tower
//####################
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
using namespace std;
vector<pair<int,int>> query(int x, int y , int z){
cout.flush();
cout <<"? "<<x<<' '<<y<<' ' <<z<<endl;
int r;cin>>r;
vector<pair<int,int>> re;
for(int i = 0 ; i < r ; i++){
int a,b;cin>>a>>b;
if(a>b)swap(a,b);
re.emplace_back(a,b);
}
cout.flush();
return re;
}
void answer(vector<int> ans){
cout.flush();
cout <<"! ";
for(int u:ans)cout <<u<<" ";
cout << endl;
cout.flush();
}
void solve(){
int n;cin>>n;
if(n==3){
answer({0,1,2});
}else{
/*
Des que on q un noeud plsu proche que neihbor, on le prend
*/
int neighbor = 1;
for(int i = 1; i < n ; i++){
for(int j = i+1 ; j < n ; j++){
auto re = query(0,i,j);
if(re.size()==2 && re[0].first == 0 && re[1].first==0){
neighbor = i;
}
}
}
vector<int> ans = {0,neighbor};
set<int> S;
S.insert(0);
S.insert(neighbor);
for(int t = 2 ; t < n ; t++){
for(int x = 0 ; x < n ; x++){
if(S.count(x)==0){
auto q = query(ans[ans.size()-1], ans[ans.size()-2],x);
if(q.size()==2){
if(q[0] == make_pair(ans[ans.size()-1], ans[ans.size()-2])){
swap(q[0], q[1]);
}
if(q[0].first == x)
swap(q[0].first, q[0].second);
S.insert(x);
if(q[0].first != ans.back() && t==2)
swap(ans[0], ans[1]);
ans.emplace_back(x);
break;
}
}
}
}
answer(ans);
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T, K;cin>>T>>K;
for(int i = 0 ; i < T ; i++){
solve();
}
return 0;
};