import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] field = new int[n + 2][n + 2]; for (int i = 0; i < n + 2; i++) { Arrays.fill(field[i], Integer.MAX_VALUE); if (i == 0 || i == n + 1) { continue; } for (int j = 1; j <= n; j++) { field[i][j] = 0; } } boolean isVertical = false; boolean isUp = true; int idx = 1; int h = 1; int w = 1; while (idx <= n * n) { field[h][w] = idx; idx++; int nextH; int nextW; if (isVertical) { if (isUp) { nextH = h + 1; } else { nextH = h - 1; } nextW = w; } else { if (isUp) { nextW = w + 1; } else { nextW = w - 1; } nextH = h; } if (field[nextH][nextW] == 0) { h = nextH; w = nextW; continue; } if (isVertical) { isVertical = false; isUp = !isUp; } else { isVertical = true; } if (isVertical) { if (isUp) { h = h + 1; } else { h = h - 1; } } else { if (isUp) { w = w + 1; } else { w = w - 1; } } } StringBuilder sb = new StringBuilder(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j != 1) { sb.append(" "); } sb.append(String.format("%03d", field[i][j])); } sb.append("\n"); } System.out.print(sb); } }