#include #include #include #include static int dig(const std::string &w, int N, int pos) { return w[static_cast(N - 1 - pos)] - '0'; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; if (!(std::cin >> N)) return 0; std::vector p(static_cast(N - 1)); for (int i = 1; i < N; ++i) { std::cout << "? 0 " << i << '\n'; std::cout.flush(); long long r; std::cin >> r; if (r == -1) return 0; p[static_cast(i - 1)] = static_cast(r); } bool allZero = true; for (int x : p) if (x != 0) allZero = false; if (allZero) { std::cout << "! -1\n"; std::cout.flush(); return 0; } std::set cand; for (int t = 1; t <= 9; ++t) { std::vector d(static_cast(N)); d[0] = t; bool ok = true; for (int i = 1; i < N; ++i) { int pr = p[static_cast(i - 1)]; if (pr % t != 0) { ok = false; break; } d[static_cast(i)] = pr / t; if (d[static_cast(i)] < 0 || d[static_cast(i)] > 9) { ok = false; break; } } if (!ok) continue; if (d[static_cast(N - 1)] == 0) continue; std::string s; s.reserve(static_cast(N)); for (int i = N - 1; i >= 0; --i) s.push_back(static_cast('0' + d[static_cast(i)])); cand.insert(std::move(s)); } if (cand.size() > 1) { int sepA = -1, sepB = -1; for (int a = 1; a < N; ++a) { for (int b = a + 1; b < N; ++b) { int v0 = -1; bool diff = false; for (const std::string &w : cand) { int pr = dig(w, N, a) * dig(w, N, b); if (v0 < 0) v0 = pr; else if (pr != v0) { diff = true; break; } } if (diff) { sepA = a; sepB = b; break; } } if (sepA >= 0) break; } if (sepA >= 0) { std::cout << "? " << sepA << " " << sepB << '\n'; std::cout.flush(); long long r; std::cin >> r; if (r == -1) return 0; std::set nxt; for (const std::string &w : cand) { if (dig(w, N, sepA) * dig(w, N, sepB) == r) nxt.insert(w); } cand = std::move(nxt); } } if (cand.size() == 1) { std::cout << "! " << *cand.begin() << '\n'; } else { std::cout << "! -1\n"; } std::cout.flush(); return 0; }