#include using namespace std; #include using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair; using lb = long double; using T = tuple; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif // Sieve of Eratosthenes // https://youtu.be/UTVg7wzMWQc?t=2774 //long longだとおそい struct Sieve { int n; vector f, primes; Sieve(int n=1):n(n), f(n+1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i*i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x;} vector factorList(int x) { vector res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector

factor(int x) { vector fl = factorList(x); if (fl.size() == 0) return {}; vector

res(1, P(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } vector> factor(ll x) { vector> res; for (int p : primes) { int y = 0; while (x%p == 0) x /= p, ++y; if (y != 0) res.emplace_back(p,y); } if (x != 1) res.emplace_back(x,1); return res; } }; int query(int i, int j) { cout << "? " << i+1 << " " << j+1 << endl; int k; cin >> k; return k; }; int main() { int n; cin >> n; Sieve s(n); int p = 0; for(int i=1;i<=n;i++){ if(s.isPrime(i)) p = i; } dbg(p); vector ans(n); rep(i,n){ ans[i] = query(0,i); } int cnt = 0; rep(i,n){ if(ans[i]%p==0) cnt++; } vector a(n), b(n); if(cnt==1){ int j = -1; rep(i,n){ if(ans[i]%p==0) { b[i] = p; j = i; } } a[0] = ans[j]/p; for(int i=1;i vs; for(int i=0;i vs; rep(i,n){ if(b[i]==1) vs.push_back(i); } int ret = query(1, vs[0]); int k = 0; if(ret%p==0){ b[vs[0]] = p; b[vs[1]] = 1; k = vs[1]; } else{ b[vs[0]] = 1; b[vs[1]] = p; k = vs[0]; } rep(i,n){ a[i] = query(i, k); } } cout << "! "; rep(i,n){ cout << a[i] << " "; } rep(i,n){ cout << b[i] << " "; } cout << endl; return 0; }