#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include #include //#include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; typedef complex C; int main() { int N, K; cin >> N >> K; if (N%(K+1) == 1) { cout << 0 << endl; cout.flush(); while (1) { int x; cin >> x; if (x >= N) break; if (N-x <= K) { cout << N-1 << endl; continue; } else { int y = x/(K+1); cout << (K+1)*(y+1) << endl; } cout.flush(); } } else { if (K >= N) cout << N-1 << endl; else { cout << 1 << endl; } cout.flush(); while (1) { int x; cin >> x; if (x >= N) break; if (N-x <= K) { cout << N-1 << endl; continue; } else { cout << x+K << endl; } cout.flush(); } } return 0; }