#include using namespace std; typedef long long int ll; int main(){ int n; cin >> n; if(n==2){ // 出力周り確認 cout << "? 1 2" << endl; int a,b; cin >> a >> b; if(a==-1){ cout << "! 2 3" << endl; } else{ cout << "! 3 2" << endl; } return 0; } vector> v; for(int i=2;i<=n*n-n;i++){ cout << "? 1 " << i << endl; int a,b; cin >> a >> b; if(a>b)swap(a,b); v.push_back({a,b}); } vector res(n*n-n,-1); set used; { int a=0,b=0,c=0,d=0; vector vv,vvv; for(int i=0;i0){ a=vv[0]; for(int i=1;i0){ c=vvv[0]; for(int i=1;ipair{ cnt++; a*=-1; b*=-1; int f=base/n,s=base%n; int c=-1; int d=-1; if(1<=f+a and f+a p=query(res[0],v[i].first,v[i].second); if(p.first==-1 or p.second==-1){ if(abs(v[i].first)!=abs(v[i].second)){ if(id==-1){ id=i+1; mx=max(abs(v[i].first),abs(v[i].second)); } else if(mxvoid{ for(int i=0;i p=query(res[0],v[i].first,v[i].second); if(p.first==-1 or p.second==-1){ res[i+1]=max(p.first,p.second); used.insert(res[i+1]); } } }; for(int i=0;i p=query(res[0],v[i].first,v[i].second); if(p.first==-1 or p.second==-1){ res[i+1]=max(p.first,p.second); used.insert(res[i+1]); check(); } else{ cout << "? " << id+1 << " " << i+2 << endl; int a,b; cin >> a >> b; if(a>b)swap(a,b); pair pp=query(res[id],a,b); map mp; mp[p.first]++; mp[p.second]++; mp[pp.first]++; mp[pp.second]++; for(auto p:mp){ if(p.second>1){ res[i+1]=p.first; used.insert(p.first); } } } } cout << "!"; for(int i:res){ cout << " " << i; } cout << endl; }