#include using namespace std; long long ask(int a, int b) { cout << "? " << a << " " << b << endl; cout.flush(); long long x; cin >> x; if (x == -1) exit(0); return x; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector d(N); int i = 0; while (i + 2 < N) { long long ab = ask(i, i+1); long long ac = ask(i, i+2); long long bc = ask(i+1, i+2); bool found = false; vector> candidates; for (int A=0; A<=9; A++) for (int B=0; B<=9; B++) for (int C=0; C<=9; C++) { if (A*B==ab && A*C==ac && B*C==bc) { candidates.push_back({A,B,C}); } } if (candidates.size() != 1) { cout << "! -1" << endl; cout.flush(); return 0; } d[i] = candidates[0][0]; d[i+1] = candidates[0][1]; d[i+2] = candidates[0][2]; done: if (!found) { cout << "! -1" << endl; cout.flush(); return 0; } i += 3; } // Handle remaining digits if (i < N) { if (i > 0) { long long p = ask(i-1, i); if (d[i-1] == 0) { // ambiguous → cannot determine cout << "! -1" << endl; cout.flush(); return 0; } d[i] = p / d[i-1]; } } if (i + 1 < N) { long long p = ask(i, i+1); if (d[i] == 0) { cout << "! -1" << endl; cout.flush(); return 0; } d[i+1] = p / d[i]; } // Build number long long X = 0, pw = 1; for (int i = 0; i < N; i++) { X += pw * d[i]; pw *= 10; } cout << "! " << X << endl; cout.flush(); }