N, K = map(int, input().split()) # ... 2 1 0 K ... 3 2 1 gr = (N - 1) % (K + 1) x = gr while 1: print(min(x, N - 1), flush = True) h = int(input()) if h >= N: break x += K + 1