#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template bool chmax(T& x, const T& y){return (x bool chmin(T& x, const T& y){return (x>y)?(x=y,true):false;}; constexpr ll MOD=998244353; constexpr ll INF=2e18; int cnt=0; int ask(int i, int j){ cnt++; cout << "? " << i+1 << " " << j+1 << endl; int x; cin >> x; return x; } int main(){ int n; cin >> n; VI pi(n), qi(n); iota(ALL(pi),0); iota(ALL(qi),0); set as, bs; for(int i=1;i<=n;i++){ as.insert(i); bs.insert(i); } VI a(n,-1), b(n,-1); VI er; int sp=-1, sq=-1; while(1){ VI q; int mq=n*n; for(auto i:qi){ int x=ask(pi.back(),i); q.push_back(x); chmin(mq,x); if(x==1){ sp=pi.back(); sq=i; } } a[pi.back()]=mq; as.erase(mq); pi.pop_back(); map mpx; REP(i,(int)q.size()){ if(mpx.find(q[i])==mpx.end()) mpx[q[i]]=qi[i]; else mpx[q[i]]=-1; } for(auto i:bs){ int l=i*mq/__gcd(i,mq); if(mpx.find(l)!=mpx.end()){ if(mpx[l]==-1) continue; er.push_back(i); b[mpx[l]]=i; } } for(auto i:er) bs.erase(i); er.clear(); VI nqi; REP(i,(int)q.size()){ if(q[i]==mq){ nqi.push_back(qi[i]); } } swap(qi,nqi); if(mq==1) break; VI p; int mp=n*n; for(auto i:pi){ int x=ask(i,qi.back()); p.push_back(x); chmin(mp,x); if(x==1){ sp=i; sq=qi.back(); } } b[qi.back()]=mp; bs.erase(mp); qi.pop_back(); map mpy; REP(i,(int)p.size()){ if(mpy.find(p[i])==mpy.end()) mpy[p[i]]=pi[i]; else mpy[p[i]]=-1; } for(auto i:as){ int l=i*mp/__gcd(i,mp); if(mpy.find(l)!=mpy.end()){ if(mpy[l]==-1) continue; er.push_back(i); a[mpy[l]]=i; } } for(auto i:er) as.erase(i); er.clear(); VI npi; REP(i,(int)p.size()){ if(p[i]==mp){ npi.push_back(pi[i]); } } swap(pi,npi); if(mp==1) break; } REP(i,n){ if(a[i]==-1) a[i]=ask(i,sq); if(b[i]==-1) b[i]=ask(sp,i); } assert(cnt<=n*3); REP(i,n) cout << a[i] << " \n"[i==n-1]; REP(i,n) cout << b[i] << " \n"[i==n-1]; return 0; }