#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; pair, vector> primes_lpf(const int n) { vector primes; primes.reserve(n / 10); vector lpf(n + 1); for (int i = 2; i <= n; i += 2) lpf[i] = 2; for (int i = 3; i <= n; i += 6) lpf[i] = 3; if (2 <= n) primes.push_back(2); if (3 <= n) primes.push_back(3); // 5 * x <= n, x <= floor(n / 5) const int n5 = n / 5; int x = 5; char add_next = 2; for (; x <= n5; x += add_next, add_next ^= 2 ^ 4) { int px = lpf[x]; if (px == 0) { lpf[x] = px = x; primes.push_back(x); } for (int i = 2;; ++i) { int q = primes[i]; int y = q * x; if (y > n) break; lpf[y] = q; if (q == px) break; } } for (; x <= n; x += add_next, add_next ^= 2 ^ 4) { if (lpf[x] == 0) { lpf[x] = x; primes.push_back(x); } } return {move(primes), move(lpf)}; } constexpr int PSIZE = 1000000; auto [primes, lpf] = primes_lpf(PSIZE); int memo[1010][1010]; } int main() { ios::sync_with_stdio(false); cin.tie(0); memset(memo, -1, sizeof(memo)); int n; cin >> n; bool flip = false; auto ask = [&](int i, int j) { if (flip) swap(i, j); if (memo[i][j] != -1) return memo[i][j]; cout << "? " << i + 1 << ' ' << j + 1 << endl; int res; cin >> res; return memo[i][j] = res; }; auto answer = [&](VI a, VI b) { if (flip) swap(a, b); cout << "!"; for (int x : a) cout << ' ' << x; for (int x : b) cout << ' ' << x; cout << endl; }; if (n == 1) { answer({1}, {1}); return 0; } int pmx = *prev(upper_bound(all(primes), n)); int ip = -1, jp = -1; rep(i, n) { if (i == n - 1) { ip = jp = n - 1; break; } int r = ask(i, i); if (r % pmx == 0) { if (ask(i, i + 1) % pmx == 0) { ip = i; } else { jp = i; } break; } } flip = ip == -1; if (flip) swap(ip, jp); VI a(n), b(n), oneb; rep(j, n) { b[j] = ask(ip, j) / pmx; if (b[j] == 1) oneb.emplace_back(j); } assert(oneb.size() == 2); int i_test = ip == 0 ? 1 : ip - 1; int j1; if (ask(i_test, oneb[0]) % pmx == 0) { b[oneb[0]] = pmx; j1 = oneb[1]; } else { b[oneb[1]] = pmx; j1 = oneb[0]; } rep(i, n) a[i] = ask(i, j1); answer(a, b); }