n,m=map(int,input().split()) a=[i%n for i in range(m)] p=list(range(n)) e=[[n]*n for i in range(n)] for i in range(n): for j in range(n): e[p[i]][p[j]]=min(e[p[i]][p[j]],abs(i-j)) for y in range(m): p[y-1],p[y]=p[y],p[y-1] for i in range(n): for j in range(n): e[p[i]][p[j]]=min(e[p[i]][p[j]],abs(i-j)) for k in range(n): for i in range(n): for j in range(n): e[i][j]=min(e[i][j],e[i][k]+e[k][j]) print(*[e[i][p[0]] for i in range(1,n)])