def main(): n = int(input()) ans = [[(i + j) % n + 1 for j in range(n)] for i in range(n)] for row in ans: print(*row) if __name__ == "__main__": main()