import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] m = new int[n + 2][n + 2]; for (int i = 0; i < n + 2; i++) { m[0][i] = -1; m[n + 1][i] = -1; m[i][0] = -1; m[i][n + 1] = -1; } int k = 1, x = 1, y = 1, tx = 0, ty = 1, tmp; while (k <= n * n) { m[x][y] = k; if (m[x + tx][y + ty] != 0) { tmp = tx; tx = ty; ty = -tmp; } x += tx; y += ty; k++; } for (int i = 1; i < n + 1; i++) { for (int j = 1; j < n + 1; j++) { System.out.printf("%03d", m[i][j]); if (j < n) { System.out.print(" "); } } System.out.println(); } } }