#include<iostream> using namespace std; int main(){ int n, k,x,maxa,maxb; cin>>n>>k; //read the number of stories and eggs string response; maxa=n; maxb=1; x=(maxa+maxb)/2; while(response != "exit"&&k>-1) { if(maxa==maxb) {cout<<"answer"<<" "<<x+1<<"\n"; cout.flush();} else if(k==0) {cout<<"answer"<<" "<<x+1<<"\n"; cout.flush();} else { cout << "query " << x << "\n"; //can also use endl for newline cout.flush(); k--;} cin >> response; if(response == "broke") maxa=x-1; else maxb=x+1; x=(maxa+maxb)/2; } return 0; }