#include using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; template using max_heap = std::priority_queue; template using min_heap = std::priority_queue, std::greater>; constexpr int popcount(const ull v) { return v ? __builtin_popcountll(v) : 0; } constexpr int log2p1(const ull v) { return v ? 64 - __builtin_clzll(v) : 0; } constexpr int lsbp1(const ull v) { return __builtin_ffsll(v); } constexpr int clog(const ull v) { return v ? log2p1(v - 1) : 0; } constexpr ull ceil2(const ull v) { return 1ULL << clog(v); } constexpr ull floor2(const ull v) { return v ? (1ULL << (log2p1(v) - 1)) : 0ULL; } constexpr bool btest(const ull mask, const int ind) { return (mask >> ind) & 1ULL; } template void bset(T& mask, const int ind) { mask |= ((T)1 << ind); } template void breset(T& mask, const int ind) { mask &= ~((T)1 << ind); } template void bflip(T& mask, const int ind) { mask ^= ((T)1 << ind); } template void bset(T& mask, const int ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); } template bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); } template bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); } template constexpr T inf_v = std::numeric_limits::max() / 4; template constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; template constexpr T TEN(const int n) { return n == 0 ? T{1} : TEN(n - 1) * T{10}; } template struct fix : F { fix(F&& f) : F{std::forward(f)} {} template auto operator()(Args&&... args) const { return F::operator()(*this, std::forward(args)...); } }; template auto nd_array(int const (&szs)[n], const T x = T{}) { if constexpr (i == n) { return x; } else { return std::vector(szs[i], nd_array(szs, x)); } } template std::ostream& operator<<(std::ostream& os, const std::array& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::deque& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::map& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::multimap& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::multiset& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::pair& v) { return (os << "<" << v.first << "," << v.second << ">"); } template std::ostream& operator<<(std::ostream& os, const std::priority_queue& v) { auto q = v; os << "["; while (not q.empty()) { os << q.top() << ",", q.pop(); } return os << "]\n"; } template std::ostream& operator<<(std::ostream& os, const std::queue& v) { auto q = v; os << "["; while (not q.empty()) { os << q.front() << ",", q.pop(); } return os << "]\n"; } template std::ostream& operator<<(std::ostream& os, const std::set& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::stack& v) { auto q = v; os << "["; while (not q.empty()) { os << q.top() << ",", q.pop(); } return os << "]\n"; } template std::ostream& print(std::ostream& os, const TupType& _tup, std::index_sequence) { return os << "(", (..., (os << (I == 0 ? "" : ", ") << std::get(_tup))), os << ")\n"; } template std::ostream& operator<<(std::ostream& os, const std::tuple& _tup) { return print(os, _tup, std::make_index_sequence()); } template std::ostream& operator<<(std::ostream& os, const std::unordered_map& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_multimap& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_multiset& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_set& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::vector& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } class printer { public: printer(std::ostream& os_ = std::cout) : m_os{os_} { m_os << std::fixed << std::setprecision(15); } template int ln(const Args&... args) { return dump(args...), m_os << '\n', 0; } template int el(const Args&... args) { return dump(args...), m_os << std::endl, 0; } private: template void dump(const T& v) { m_os << v; } template void dump(const std::vector& vs) { for (int i = 0; i < (int)vs.size(); i++) { m_os << (i ? " " : ""), dump(vs[i]); } } template void dump(const std::vector>& vss) { for (int i = 0; i < (int)vss.size(); i++) { m_os << (0 <= i or i + 1 < (int)vss.size() ? "\n" : ""), dump(vss[i]); } } template int dump(const T& v, const Args&... args) { return dump(v), m_os << ' ', dump(args...), 0; } std::ostream& m_os; }; printer out; class scanner { public: scanner(std::istream& is_ = std::cin) : m_is{is_} { m_is.tie(nullptr), std::ios::sync_with_stdio(false); } void reset_opt() { m_is.tie(), std::ios::sync_with_stdio(); } template T val() { T v; return m_is >> v, v; } template T val(const T offset) { return val() - offset; } template std::vector vec(const int n) { return make_v(n, [this]() { return val(); }); } template std::vector vec(const int n, const T offset) { return make_v(n, [this, offset]() { return val(offset); }); } template std::vector> vvec(const int n0, const int n1) { return make_v>(n0, [this, n1]() { return vec(n1); }); } template std::vector> vvec(const int n0, const int n1, const T offset) { return make_v>(n0, [this, n1, offset]() { return vec(n1, offset); }); } template auto tup() { return std::tuple...>{val()...}; } template auto tup(const Args&... offsets) { return std::tuple...>{val(offsets)...}; } private: template std::vector make_v(const int n, F f) { std::vector ans; for (int i = 0; i < n; i++) { ans.push_back(f()); } return ans; } std::istream& m_is; }; scanner in; template void HogeHogeSansuu(T x) { std::cerr << x; } template void HogeHogeSansuu(T x, Args... args) { std::cerr << x << ",", HogeHogeSansuu(args...); } int main() { in.reset_opt(); const int N = in.val(); const int L = N * N - N; using pii = std::pair; auto ask = [&](const int i, const int j) { out.el('?', i + 1, j + 1); const auto [p, q] = in.tup(); return std::make_pair(p, q); }; auto fin = [&](const std::vector& ans) { out.el('!', ans); }; auto diff = [&](const int m, const int n) { const auto [p, q] = std::minmax({m / N - n / N, m % N - n % N}); return std::make_pair(p, q); }; std::vector ds(L, {0, 0}); for (int i = 1; i < L; i++) { ds[i] = ask(i, 0); } std::vector as(L, -1); const int mi = std::min_element(ds.begin(), ds.end()) - ds.begin(); const int Mi = std::max_element(ds.begin(), ds.end()) - ds.begin(); as[mi] = N, as[Mi] = N * N - 1; auto getcand = [&](const int n, const pii d) { std::vector ans; for (int c = N; c < N * N; c++) { if (diff(n, c) == d) { ans.push_back(c); } } return ans; }; auto decide = [&](const int m, const pii& md, const int n, const pii& nd) { std::vector ans; const auto cs = getcand(m, md); for (const int c : cs) { assert(diff(m, c) == md); if (diff(n, c) == nd) { ans.push_back(c); } } assert(ans.size() == 1); return ans[0]; }; as[0] = decide(N, ds[mi], N * N - 1, ds[Mi]); (std::cerr << "LINE " << 54 << ": " << "(" << "as[0], mi, Mi" << ") = ("), HogeHogeSansuu(as[0], mi, Mi), std::cerr << ")" << std::endl; int ref = mi; { const int p = as[0] / N, q = as[0] % N; if ((p + q) % 2 == 1) { ref = Mi; } } std::vector used(N * N, false); used[N] = used[as[0]] = used[N * N - 1] = true; for (int i = 1; i < L; i++) { const auto cs = getcand(as[0], pii{-ds[i].second, -ds[i].first}); (std::cerr << "LINE " << 65 << ": " << "(" << "i, cs" << ") = ("), HogeHogeSansuu(i, cs), std::cerr << ")" << std::endl; if (cs.size() == 1) { as[i] = cs[0]; } else if (cs.size() == 2) { if (used[cs[0]]) { as[i] = cs[1]; } else if (used[cs[1]]) { as[i] = cs[0]; } else { const auto d = ask(ref, i); as[i] = decide(as[0], pii{-ds[i].second, -ds[i].first}, as[ref], d); } } else { assert(false); } (std::cerr << "LINE " << 80 << ": " << "(" << "i, as[i]" << ") = ("), HogeHogeSansuu(i, as[i]), std::cerr << ")" << std::endl; used[as[i]] = true; } fin(as); return 0; }