n = int(input())

ans = [[0] * n for i in range(n)]
tmp = [[0] * n for i in range(n)]
for i in range(n):
    for j in range(n):
        k = (j - i + n) % n
        ans[i][j] = k * (n**i)

for i in range(n):
    for j in range(n):
        tmp[i][j] = ans[i][j] + ans[j][i]

for i in range(n):
    print(" ".join(list(map(str, tmp[i]))))
    