import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(), H = 0, W = 0, ans[][] = new int[N][N], tmp = 0; sc.close(); for (int i = 0; i < N * N; ++i) { ans[H][W] = i + 1; if (tmp % 4 == 0) { if (W >= N - 1 || ans[H][W + 1] != 0) { ++H; ++tmp; } else ++W; } else if (tmp % 4 == 1) { if (H >= N - 1 || ans[H + 1][W] != 0) { --W; ++tmp; } else ++H; } else if (tmp % 4 == 2) { if (W <= 0 || ans[H][W - 1] != 0) { --H; ++tmp; } else --W; } else { if (H <= 0 || ans[H - 1][W] != 0) { ++W; ++tmp; } else --H; } } for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) System.out.printf("%03d ", ans[i][j]); System.out.println(); } } }