#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect from heapq import * import typing mod=1000000007 import sys input = sys.stdin.readline from itertools import accumulate n = int(input()) ans = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): ans[i][j] = (i + j) % n + 1 for i in range(n): print(*ans[i])