import java.util.Arrays; import java.util.Scanner; public class Yukicoder401 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), cnt = 1; int[] res = new int[n * n]; Arrays.fill(res, 0); int x = 0, y = 0, dx = 1, dy = 0; while (cnt <= n * n) { res[y * n + x] = cnt++; if ((x + dx) < 0 || (x + dx) > n - 1 || (y + dy) < 0 || (y + dy) > n - 1 || res[(y + dy) * n + (x + dx)] != 0) { if (dx == 1) { dx = 0; dy = 1; } else if (dy == 1) { dx = -1; dy = 0; } else if (dx == -1) { dx = 0; dy = -1; } else if (dy == -1) { dx = 1; dy = 0; } } x += dx; y += dy; } for (y = 0; y < n; y++) { for (x = 0; x < n; x++) { System.out.printf("%03d ", res[y * n + x]); } System.out.println(""); } } }