#include <bits/stdc++.h>
#define uset unordered_set
using namespace std;
int main() {
int d;
cout << "query 0\n";
cout.flush(); cin >> d;
string ans = "";
for (int digit = 0; digit <= 17; digit++) {
int l = 1, r = 10;
while(r >= l) {
int mid = (l+r)/2;
if (mid == 10 && digit == 17) {l = 10; break}
int digitsum;
cout << "query " << mid << string(digit, '0') << "\n"; cout.flush();
cin >> digitsum;
if (digitsum > d) l = mid+1;
if (digitsum <= d) r = mid-1;
}
// cout << l << " " << r << "\n";
ans.push_back(10 - min(l,10) + '0');
}
reverse(ans.begin(), ans.end());
bool number = false;
for (char c : ans) {
if (c != '0' || number) {
number = true; cout << c;
}
}
}