import sys N,K=map(int,input().split()) x=0 while True: if N==1: print(0) else: d = (N-1-x)%K if d==0:d=K if d<0:d+=K print(x+d, flush=True) x = int(input()) if x>N:break