import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); private static int[][] ary; public static void main(String[] args) throws Exception { int n = sc.nextInt(); move(n); show(n); } public static void move(int n) { ary = new int[n][n]; int x = 0; int y = 0; int[] dx = {0, 1, 0, -1}; int[] dy = {1, 0, -1, 0}; int d = 0; for (int i = 1;i <= n*n;i++) { ary[x][y] = i; int nx = x + dx[d]; int ny = y + dy[d]; if (nx < 0 || n <= nx || ny < 0 || n <= ny) { d = (d+1)%4; nx = x + dx[d]; ny = y + dy[d]; } else if (ary[nx][ny] > 0) { d = (d+1)%4; nx = x + dx[d]; ny = y + dy[d]; } x = nx; y = ny; } } public static void show(int n) { for (int i = 0;i < n;i++) { StringBuilder sb = new StringBuilder(); for (int j = 0;j < n;j++) { sb.append(String.format("%03d", ary[i][j])).append(" "); } System.out.println(sb.substring(0, sb.length()-1)); } } }