n = int(input()) matrix = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): for j in range(n): diff = abs(i - j) matrix[i][j] = diff for row in matrix: print(*row)