#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair P; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; int next() { int res; scanf("%d", &res); return res; } int main() { int n, k; cin >> n >> k; if (n == k + 2 || n == 1) { puts("0"); fflush(stdout); if (next() < n) { printf("%d\n", n - 1); fflush(stdout); next(); } } else if (n - 1 <= k) { printf("%d\n", n - 1); fflush(stdout); next(); } else { int st = (n - 1) % (k + 1); if (st == 0) puts("0"); else printf("%d\n", st); fflush(stdout); while (true) { int now = next(); if (now >= n) break; int out = now + (now + st) % (k + 1); if (now == out) out += k - 1; printf("%d\n", out); fflush(stdout); } } return 0; }