#include using namespace std; using lint = long long; using pint = pair; using plint = pair; struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template void ndarray(vector& vec, const V& val, int len) { vec.assign(len, val); } template void ndarray(vector& vec, const V& val, int len, Args... args) { vec.resize(len), for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); }); } template bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } int floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); } template pair operator+(const pair &l, const pair &r) { return make_pair(l.first + r.first, l.second + r.second); } template pair operator-(const pair &l, const pair &r) { return make_pair(l.first - r.first, l.second - r.second); } template vector sort_unique(vector vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } template istream &operator>>(istream &is, vector &vec) { for (auto &v : vec) is >> v; return is; } template ostream &operator<<(ostream &os, const vector &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; } #if __cplusplus >= 201703L template istream &operator>>(istream &is, tuple &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; } template ostream &operator<<(ostream &os, const tuple &tpl) { std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os; } #endif template ostream &operator<<(ostream &os, const deque &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; } template ostream &operator<<(ostream &os, const set &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template ostream &operator<<(ostream &os, const unordered_set &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template ostream &operator<<(ostream &os, const multiset &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template ostream &operator<<(ostream &os, const unordered_multiset &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; } template ostream &operator<<(ostream &os, const pair &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; } template ostream &operator<<(ostream &os, const map &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; } template ostream &operator<<(ostream &os, const unordered_map &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; } #ifdef HITONANODE_LOCAL #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl #else #define dbg(x) {} #endif pint query(int i, int j) { cout << "? " << i + 1 << ' ' << j + 1 << endl; int x, y; cin >> x >> y; return make_pair(x, y); } pint simulate(pint pi, pint pj) { pint ret = pi - pj; if (ret.first > ret.second) swap(ret.first, ret.second); return ret; } int main() { int N; cin >> N; const int L = N * N - N; vector ans(L); map mp; map> p2i; mp[0] += 2; FOR(i, 1, L) { ans[i] = query(i, 0); p2i[ans[i]].emplace_back(i); if (ans[i].first * ans[i].second == 0) mp[ans[i].first + ans[i].second]++; } int lo = mp.begin()->first; int hi = prev(mp.end())->first; int lo2 = lo, hi2 = hi; while (mp[lo2] == 1) lo2++; while (mp[hi2] == 1) hi2--; int d1 = hi2 - lo, d2 = hi - lo2; vector ret(L, pint(-1, -1)); if (d1 > d2) { ret[0] = make_pair(-lo2 + 1, -lo); // (十, 一) } else { ret[0] = make_pair(-lo + 1, -lo2); } for (auto [p, is] : p2i) { pint pa = p; if (is.size() == 1) { int i = is[0]; pint pcand = ret[0] + pa; if (pcand.first >= 1 and pcand.first < N and pcand.second >= 0 and pcand.second < N) ret[i] = pcand; else { swap(pa.first, pa.second); ret[i] = ret[0] + pa; } } else { int i = is[0], j = is[1]; pint p1 = ret[0] + pa; swap(pa.first, pa.second); pint p2 = ret[0] + pa; pint p = query(i, j); if (simulate(p1, p2) != p) swap(p1, p2); ret[i] = p1, ret[j] = p2; } } cout << "! "; for (auto x : ret) cout << x.first * N + x.second << ' '; cout << endl; }