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