// Arup Guha
// 7/27/2026
// Solution to 1989 UCF HS Programming Contest Problem: Latin Square

import java.util.*;

public class latin {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		
		while (stdin.hasNext()) {
			
			// Get size.
			int n = stdin.nextInt();
		
			int[][] sq = new int[n][n];
			for (int i=0; i<n; i++) {
				for (int j=1; j<=n; j++) {
				
					// There's shorter ways to do this, but I think this is easier to follow
					int res = (j+i)%n;
					if (res == 0) res = n;
					sq[i][j-1] = res;
				}
			}
			
			// Here's the square.
			for (int i=0; i<n; i++) {
				for (int j=0; j<n; j++)
					System.out.print(sq[i][j]+" ");
				System.out.println();
			}
			
			// Since I am making data for this set, I am going to say anytime they say
			// "blank lines between cases", that they really mean "put a blank lines
			// after each case". This is what the judges did anyway. They really didn't
			// do a good job specifying formatting in the early days.
			System.out.println();
		}
	}
}