N = int(input()) res = [[0 for j in range(N)] for i in range(N)] res[0][0] = 1 for j in range(1, N): res[0][j] = (res[0][j - 1] - 2) % 5 + 1 for j in range(N): for i in range(1, N): res[i][j] = (res[i - 1][j] + 1) % 5 + 1 for r in res: print(*r)