import sys, math sys.setrecursionlimit(1000000) INF = 1 << 100 #mod = 1000000007 mod = 998244353 input = lambda: sys.stdin.readline().rstrip() li = lambda: list(map(int, input().split())) N = int(input()) ans = [[0] * N for _ in range(N)] x = 0 for i in range(N): for j in range(N): ans[j][(j+x)%N] = i+1 x += 1 for a in ans: print(*a)