#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define dbg(x) (cout<<#x<<" = "<<(x)<<'\n') #ifdef HOME const string inputFile = "input.txt"; const string outputFile = "output.txt"; #else const string problemName = ""; const string inputFile = problemName + ".in"; const string outputFile = problemName + ".out"; #endif typedef long long int lld; typedef pair PII; typedef pair PIL; typedef pair PLI; typedef pair PLL; const int INF = (1LL << 31) - 1; const lld LINF = (1LL << 62) - 1; const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1}; const int MOD = (int)(1e9) + 7; const int NMAX = 100000 + 5; const int MMAX = 100000 + 5; const int KMAX = 100000 + 5; const int PMAX = 100000 + 5; const int LMAX = 100000 + 5; const int VMAX = 100000 + 5; int main() { #ifdef HOME freopen(inputFile.c_str(), "r", stdin); freopen(outputFile.c_str(), "w", stdout); #endif int n, k, i, s; cin >> n >> k; //read the number of stories and eggs string response; if(k == 1) { for(i = 1; i <= n; i++) { cout << "query " << i << '\n'; cout.flush(); cin >> response; if(response == "broke") break; } cout << "answer " << i - 1 << '\n'; cout.flush(); } else { // stiu pentru k = 2 for(s = 0, i = 1; s + i <= n; i++) s += i; s = 0; for(; s + i <= n; i--) { cout << "query " << s + i << '\n'; cout.flush(); cin >> response; if(response == "broke") break; s += i; } if(response != "broke") s += i; if(s < n) { for(s++; s <= n; s++) { cout << "query " << s << '\n'; cout.flush(); cin >> response; if(response == "broke") break; } } else s = n + 1; cout << "answer " << s - 1 << '\n'; cout.flush(); } return 0; }