# jos_perm 
# Fig. 47.4 
# input 10 2

n,k = map(int, input("n k=? ").split())
s = 0
while s < n:
  s += 1
  x = k*s
  while x > n:
    x = int((k*(x-n)-1)/(k-1))
  print(x, end =' ')
