#include using namespace std; long long ask(int a, int b) { if (a > b) swap(a, b); cout << "? " << a << ' ' << b << '\n'; cout.flush(); long long p; cin >> p; if (p == -1) exit(0); return p; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int leadPos = N - 1; // most significant digit, nonzero vector p(N, -1); // p[i] = digit[i] * digit[leadPos] for i < leadPos for (int i = 0; i < leadPos; i++) { p[i] = ask(i, leadPos); } vector nonzero; for (int i = 0; i < leadPos; i++) { if (p[i] != 0) nonzero.push_back(i); } // If fewer than 2 nonzero lower digits exist, one extra query cannot resolve the scale. if ((int)nonzero.size() < 2) { cout << "! -1\n"; cout.flush(); return 0; } int a = nonzero[0]; int b = nonzero[1]; long long q = ask(a, b); vector> cand; for (int lead = 1; lead <= 9; lead++) { vector d(N, -1); d[leadPos] = lead; bool ok = true; for (int i = 0; i < leadPos; i++) { if (p[i] % lead != 0) { ok = false; break; } d[i] = (int)(p[i] / lead); if (d[i] < 0 || d[i] > 9) { ok = false; break; } } if (!ok) continue; if (1LL * d[a] * d[b] != q) continue; cand.push_back(d); } if ((int)cand.size() != 1) { cout << "! -1\n"; cout.flush(); return 0; } // Build the answer as a string: most significant digit first string X; for (int i = N - 1; i >= 0; i--) { X.push_back(char('0' + cand[0][i])); } cout << "! " << X << '\n'; cout.flush(); return 0; }