Problem: You've got an n × n × n cube, split into unit cubes. Your task is to number all unit cubes in this cube with positive integers from 1 to n3 so that: 

  * each number was used as a cube's number exactly once; 
  * for each 1 ≤ i < n3, unit cubes with numbers i and i + 1 were neighbouring (that is, shared a side); 
  * for each 1 ≤ i < n there were at least two different subcubes with sizes i × i × i, made from unit cubes, which are numbered with consecutive numbers. That is, there are such two numbers x and y, that the unit cubes of the first subcube are numbered by numbers x, x + 1, ..., x + i3 - 1, and the unit cubes of the second subcube are numbered by numbers y, y + 1, ..., y + i3 - 1. 



Find and print the required numeration of unit cubes of the cube.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the size of the cube, whose unit cubes need to be numbered.

Output

Print all layers of the cube as n n × n matrices. Separate them with new lines. Print the layers in the order in which they follow in the cube. See the samples for clarifications. 

It is guaranteed that there always is a solution that meets the conditions given in the problem statement.

Examples

Input

3


Output

1 4 17 
2 3 18 
27 26 19 

8 5 16 
7 6 15 
24 25 20 

9 12 13 
10 11 14 
23 22 21 

Note

In the sample the cubes with sizes 2 × 2 × 2 are numbered with integers 1, ..., 8 and 5, ..., 12.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int N, a[55][55][55], b[55][55][55];
void go(int x, int y, int z, int dx, int dy, int dz, int p, int n, int m,
        int sp, int dp) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      a[x][y][z] = sp, sp += dp;
      if (j < m)
        x += dx, y += dy, z += dz;
      else {
        if (p == 1 || p == -1)
          x += p, dy *= -1, dz *= -1;
        else if (p == 2 || p == -2)
          y += p / 2, dx *= -1, dz *= -1;
        else
          z += p / 3, dx *= -1, dy *= -1;
      }
    }
}
void add(int n) {
  int s = n * n * n;
  go(1, 0, 1, 0, 0, 1, 1, n, n, 0, -1);
  if (n & 1) {
    go(0, n, 1, 0, 0, 1, -2, n + 1, n, s + 1, 1);
    go(0, 0, 0, 0, 1, 0, 1, n + 1, n + 1, s + n * (n + 1) + 1, 1);
    for (int i = 1; i <= n + 1; i++)
      for (int j = 1; j <= n + 1; j++)
        for (int k = 1; k <= n + 1; k++)
          b[i][j][k] = a[n - i + 1][k - 1][n - j + 1] + n * n;
  } else {
    go(0, n, 1, 0, -1, 0, 3, n, n + 1, s + 1, 1);
    go(0, n, n + 1, 0, -1, 0, 1, n + 1, n + 1, s + n * (n + 1) + 1, 1);
    for (int i = 1; i <= n + 1; i++)
      for (int j = 1; j <= n + 1; j++)
        for (int k = 1; k <= n + 1; k++)
          b[i][j][k] = a[n - i + 1][k - 1][j] + n * n;
  }
  memcpy(a, b, sizeof(b));
}
void doit() {
  scanf("%d", &N), a[1][1][1] = 1;
  for (int i = 1; i < N; i++) add(i);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      for (int k = 1; k <= N; k++)
        printf("%d%c", a[i][j][k], k == N ? '\n' : ' ');
    if (i < N) puts("");
  }
}
int main() {
  doit();
  return 0;
}