import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } string COLOR(string s = "") { return "\x1b[" ~ s ~ "m"; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } uint xrand() { static uint x = 314159265, y = 358979323, z = 846264338, w = 327950288; uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8; } int N; debug { int[] A, B; } int Ask(int i, int j) { debug { const l = lcm(A[i], B[j]); writeln(i, " ", j, ": ", A[i], " ", B[j], "; ", l); return l; } else { writefln("? %s %s", i + 1, j + 1); stdout.flush; const l = readInt; return l; } } void Answer(int[] as, int[] bs) { write("!"); foreach (i; 0 .. N) write(" ", as[i]); foreach (j; 0 .. N) write(" ", bs[j]); writeln; stdout.flush; import core.stdc.stdlib; exit(0); } void main() { N = readInt; debug { A = iota(1, N + 1).array; B = iota(1, N + 1).array; foreach (i; 0 .. N) swap(A[xrand() % (i + 1)], A[i]); foreach (i; 0 .. N) swap(B[xrand() % (i + 1)], B[i]); writeln("A = ", A); writeln("B = ", B); } auto lpf = iota(N + 1).array; int P; for (int p = 2; p <= N; ++p) if (lpf[p] == p) { chmax(P, p); for (int n = 2 * p; n <= N; n += p) chmin(lpf[n], p); } auto as = new int[N]; auto bs = new int[N]; void checkA(int jm) { foreach (i; 0 .. N - 1) { const res = Ask(i, jm); if (res == P) { const res1 = Ask(i, (jm + 1) % N); if (res1 % P == 0) { as[i] = P; } else { as[i] = 1; } } else { as[i] = res / P; } } as[N - 1] = N * (N + 1) / 2 - as[0 .. N - 1].sum; } void checkB(int im) { foreach (j; 0 .. N - 1) { const res = Ask(im, j); if (res == P) { const res1 = Ask((im + 1) % N, j); if (res1 % P == 0) { bs[j] = P; } else { bs[j] = 1; } } else { bs[j] = res / P; } } bs[N - 1] = N * (N + 1) / 2 - bs[0 .. N - 1].sum; } if (N == 1) { as[0] = 1; bs[0] = 1; } else { auto cs = new int[N]; foreach (j; 0 .. N) cs[j] = Ask(0, j); int jm = -1; foreach (j; 0 .. N) if (cs[j] % P == 0) { if (jm != -1) jm = -2; if (jm == -1) jm = j; } if (jm == -2) { // A[0] = p checkB(0); jm = -1; foreach (j; 0 .. N) if (bs[j] == P) jm = j; checkA(jm); } else { // B[jm] = p checkA(jm); int im = -1; foreach (i; 0 .. N) if (as[i] == P) im = i; checkB(im); } } Answer(as, bs); }