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; } real readReal() { return readToken.to!real; } 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)); } int N; debug { int[] A; } alias Pair = Tuple!(int, "p", int, "q"); Pair Ask(int i, int j) { writefln("? %s %s", i + 1, j + 1); stdout.flush; int p, q; debug { p = A[i] / N - A[j] / N; q = A[i] % N - A[j] % N; if (p > q) { swap(p, q); } } else { p = readInt(); q = readInt(); } return Pair(p, q); } void main() { N = readInt(); debug { A = new int[N^^2 - N]; foreach (i; 0 .. N^^2 - N) { A[i] = readInt(); } } auto ans = new int[N^^2 - N]; alias Entry = Tuple!(Pair, "val", int, "id"); Entry[] es; foreach (i; 1 .. N^^2 - N) { const res = Ask(i, 0); es ~= Entry(res, i); } const esLen = cast(int)(es.length); es.sort; Pair mn = Pair(0, 0); Pair mx = Pair(0, 0); foreach (ref e; es) { if (mn.p + mn.q > e.val.p + e.val.q) mn = e.val; if (mx.p + mx.q < e.val.p + e.val.q) mx = e.val; } debug { writeln("mn = ", mn); writeln("mx = ", mx); } int[] a0s; foreach (s; 0 .. 2) foreach (t; 0 .. 2) { const x0mn = 1 - (s ? mn.q : mn.p); const y0mn = 0 - (s ? mn.p : mn.q); const x0mx = N - 1 - (t ? mx.q : mx.p); const y0mx = N - 1 - (t ? mx.p : mx.q); debug { writefln("(%s, %s), (%s, %s)", x0mn, y0mn, x0mx, y0mx); } if (x0mn == x0mx && y0mn == y0mx) { a0s ~= x0mn * N + y0mn; } } a0s = a0s.sort.uniq.array; assert(a0s.length == 1); ans[0] = a0s[0]; for (int x = 0, y; x < esLen; x = y) { for (y = x; y < esLen && es[x].val == es[y].val; ++y) {} const x1 = ans[0] / N + es[x].val.p; const y1 = ans[0] % N + es[x].val.q; const x2 = ans[0] / N + es[x].val.q; const y2 = ans[0] % N + es[x].val.p; if (y - x == 1) { const i = es[x].id; if (1 <= x1 && x1 <= N - 1 && 0 <= y1 && y1 <= N - 1) { ans[i] = x1 * N + y1; } else { ans[i] = x2 * N + y2; } } else if (y - x == 2) { const i = es[x].id; const j = es[x + 1].id; const res = Ask(j, i); if ((x2 - x1 == res.p && y2 - y1 == res.q) || (x2 - x1 == res.q && y2 - y1 == res.p)) { ans[i] = x1 * N + y1; ans[j] = x2 * N + y2; } else { ans[i] = x2 * N + y2; ans[j] = x1 * N + y1; } } else { for(;;){} assert(false); } } write("!"); foreach (i; 0 .. N^^2 - N) { write(" ", ans[i]); } writeln; stdout.flush; }