N = int(input()) A = [1] for i in range (0, N-1): A.append(N-i) for i in range (0, N): print(*A) if N >= 3: A = A[N-2:N]+A[0:N-2]