import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static final int[][] move_dirs = { { 1, 0}, { 0, 1}, {-1, 0}, { 0,-1} }; public static boolean in_range(int x, int y, int W, int H){ return 0 <= x && x < W && 0 <= y && y < H; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[][] map = new int[N][N]; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ map[i][j] = Integer.MAX_VALUE; } } int cx = 0, cy = 0, dir = 0; int cnt = 1; while(map[cy][cx] >= cnt){ map[cy][cx] = cnt; cnt++; //System.out.println(cy + " " + cx); for(int next = 0; next < move_dirs.length; next++){ final int next_dir = (dir + next) % move_dirs.length; final int nx = cx + move_dirs[next_dir][0]; final int ny = cy + move_dirs[next_dir][1]; if(!in_range(nx, ny, N, N)){ continue; }else if(map[ny][nx] < cnt){ continue; }else{ cx = nx; cy = ny; break; } } } for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ System.out.printf("%s%03d", j == 0 ? "" : " ", map[i][j]); } System.out.println(); } } }