#include using namespace std; bool survives(int x) { string response; cout << "query " << x << "\n"; cout.flush(); cin >> response; return response == "survived"; } void printAnswer(int x) { string response; cout << "answer " << x << "\n"; cout.flush(); cin >> response; exit(0); } void solve(int st, int dr, int k) { int n = dr - st + 1; if (n == 1) { printAnswer(st); } else if (k == 1) { if (survives(st)) { solve(st + 1, dr, k); } else { printAnswer(st); } } else if ((1 << k) < n) { int step = (int) (ceil(pow((double) n, 1.0 / k) - 1e-6) + 0.5); int x = st + step - 1; if (survives(x)) { solve(x + 1, dr, k); } else { solve(st, x, k - 1); } } else { int m = (st + dr) / 2; if (survives(m)) { solve(m + 1, dr, k); } else { solve(st, m, k - 1); } } } int main() { // freopen("date.in", "r", stdin); // freopen("date.out","w", stdout); int N, K; cin >> N >> K; solve(1, N, K); return 0; }