var n,k,i,j:comp;begin repeat read(n,k);for i:=-n to-1do begin j:=-1;for n:=-i to n do j:=(j+k)mod n;write(j+1,(" ")[2+1div i])end until 1=0end.