#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N; cin >> N; auto query = [](int i, int j) -> pii { ++i; ++j; cout << "? " << i << " " << j << endl; int p, q; cin >> p >> q; return {p, q}; }; if (N == 2) { auto res = query(0, 1); if (res.second == 1) puts("! 1 2"); else puts("! 2 1"); return 0; } vector res(N * N - N); FOR(i, 1, res.size()) res[i] = query(0, i); const int bias = N; vector cnt(2 * N); FOR(i, 1, res.size()) { ++cnt[res[i].first + bias]; ++cnt[res[i].second + bias]; } int mx = -INF, mn = INF; REP(i, cnt.size()) { if (!cnt[i]) continue; chmax(mx, i - bias); chmin(mn, i - bias); } vector ans(res.size(), {-INF, -INF}); if (cnt[mn + bias] == N || cnt[mn + bias] == 2 * N - 1 || cnt[mn + bias] == 2 * N - 2) ans[0] = {N - 1 + mn, mx};// A_1 <= B_1 else ans[0] = {1 + mx, N - 1 + mn}; // A_1 > B_1 map> mm; // (p, q) = {idx...} FOR(i, 1, res.size()) mm[res[i]].emplace_back(i); int tidx = 0; for (const auto & [p, vec] : mm) { if (vec.size() != 1) continue; int t1 = ans[0].first - p.first, t2 = ans[0].second - p.second; if (!(1 <= t1 && t1 < N && 0 <= t2 && t2 < N)) { t1 = ans[0].first - p.second; t2 = ans[0].second - p.first; } ans[vec[0]] = {t1, t2}; if (ans[0].first <= ans[0].second && ans[vec[0]] == pii{N - 1, 0}) tidx = vec[0]; if (ans[0].first > ans[0].second && ans[vec[0]] == pii{1, N - 1}) tidx = vec[0]; } for (const auto & [p, vec] : mm) { if (vec.size() == 1) continue; auto q = tidx == 0 ? res[vec[0]] : query(tidx, vec[0]); pii pred1 {ans[0].first - p.first, ans[0].second - p.second}; pii pred2 {ans[0].first - p.second, ans[0].second - p.first}; if (ans[0].first <= ans[0].second) ans[vec[0]] = {N - 1 - q.second, 0 - q.first}; else ans[vec[0]] = {1 - q.first, N - 1 - q.second}; ans[vec[1]] = ans[vec[0]] == pred1 ? pred2 : pred1; } cout << "! "; REP(i, ans.size()) cout << ans[i].first * N + ans[i].second << " \n"[i + 1 == ans.size()]; cout << flush; }