n = int(input()) m = [str(x) for x in list(range(1,n+1))] for i in range(n): print(' '.join(m)) m.append(m.pop(0))