import java.util.Scanner; public class Main { public static void print(final int N, int[][] matrix){ for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(j != 0){ System.out.print(" "); } System.out.print(matrix[i][j]); } System.out.println(); } } public static int[][] SiamessMethod(final int N){ int[][] matrix = new int[N][N]; for(int current = 1, x = N / 2, y = 0; current <= N *N; current++, x = (x + 1) % N, y = (N + y - 1) % N){ if(matrix[y][x] != 0){ x = (N + x - 1) % N; y = (y + 2) % N; } matrix[y][x] = current; } return matrix; } public static int[][] DurerMethod(final int N){ int[][] matrix = new int[N][N]; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(((i % 4 == 0) || (i % 4 == 3)) && ((j % 4 == 0) || (j % 4 == 3))){ matrix[i][j] = (i * N) + j + 1; }else if(((i % 4 == 1) || (i % 4 == 2)) && ((j % 4 == 1) || (j % 4 == 2))){ matrix[i][j] = (i * N) + j + 1; } } } for(int i = N - 1; i >= 0; i--){ for(int j = N - 1; j >= 0; j--){ if(((i % 4 == 0) || (i % 4 == 3)) && ((j % 4 == 1) || (j % 4 == 2))){ matrix[i][j] = N * N - ((i * N) + j); }else if(((i % 4 == 1) || (i % 4 == 2)) && ((j % 4 == 0) || (j % 4 == 3))){ matrix[i][j] = N * N - ((i * N) + j); } } } return matrix; } public static int[][] LUXMethod(final int N){ final int n = (N - 2) / 4; final int small_N = n * 2 + 1; int[][] small_matrix = SiamessMethod(small_N); for(int i = 0; i < small_N; i++){ for(int j = 0; j < small_N; j++){ small_matrix[i][j] = (small_matrix[i][j] - 1) * 4; } } final int[][] L = {{4, 1}, {2, 3}}; final int[][] U = {{1, 4}, {2, 3}}; final int[][] X = {{1, 4}, {3, 2}}; int[][] matrix = new int[N][N]; for(int i = 0; i < small_N; i++){ for(int j = 0; j < small_N; j++){ final int base_y = i * 2; final int base_x = j * 2; for(int k = 0; k < 2; k++){ for(int l = 0; l < 2; l++){ final int y = base_y + k; final int x = base_x + l; if(i == small_N - 1){ matrix[y][x] = small_matrix[i][j] + X[k][l]; }else if(i == small_N - 2 && j != small_N / 2){ matrix[y][x] = small_matrix[i][j] + U[k][l]; }else if(i == small_N - 3 && j == small_N / 2){ matrix[y][x] = small_matrix[i][j] + U[k][l]; }else{ matrix[y][x] = small_matrix[i][j] + L[k][l]; } } } } } return matrix; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[][] matrix = null; if(N % 2 != 0){ matrix = SiamessMethod(N); }else if(N % 4 ==0){ matrix = DurerMethod(N); }else{ matrix = LUXMethod(N); } print(N, matrix); } }