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;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <typename T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <typename T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <typename T>
inline void println(T first) {
  print(first), putchar('\n');
}
template <typename T>
inline void printsp(T first) {
  print(first), putchar(' ');
}
template <class T, class T1>
inline void print(T first, T1 second) {
  printsp(first), println(second);
}
template <class T, class T1, class T2>
inline void print(T first, T1 second, T2 z) {
  printsp(first), printsp(second), println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
struct point {
  int first, second, z;
  point(int first = 0, int second = 0, int z = 0)
      : first(first), second(second), z(z) {}
  point px() { return point(first + 1, second, z); }
  point nx() { return point(first - 1, second, z); }
  point py() { return point(first, second + 1, z); }
  point ny() { return point(first, second - 1, z); }
  point pz() { return point(first, second, z + 1); }
  point nz() { return point(first, second, z - 1); }
} q[250000 << 1];
int st[55];
void pre() {
  int L = 250000, R = 250000 + 1;
  q[L] = point(0, 0, 0);
  q[R] = point(1, 0, 0);
  st[1] = L;
  for (int n = 2; n <= 50; n += 2) {
    q[L - 1] = q[L].pz();
    L--;
    q[R + 1] = q[R].pz();
    R++;
    for (int i = 0; i < n - 2; i++) {
      q[L - 1] = q[L].ny(), L--;
      q[R + 1] = q[R].nx(), R++;
    }
    for (int i = 0; i < n - 2; i++) q[R + 1] = q[R].py(), R++;
    for (int i = 0; i < n / 2 - 1; i++) {
      q[R + 1] = q[R].px(), R++;
      for (int j = 0; j < n - 3; j++) q[R + 1] = q[R].ny(), R++;
      q[R + 1] = q[R].px(), R++;
      for (int j = 0; j < n - 3; j++) q[R + 1] = q[R].py(), R++;
    }
    q[L - 1] = q[L].ny(), L--;
    for (int i = 0; i < n / 2; i++) {
      if (i) q[L - 1] = q[L].px(), L--;
      for (int j = 0; j < n - 1; j++) q[L - 1] = q[L].nz(), L--;
      q[L - 1] = q[L].px(), L--;
      for (int j = 0; j < n - 1; j++) q[L - 1] = q[L].pz(), L--;
    }
    q[R + 1] = q[R].py(), R++;
    for (int i = 0; i < n / 2; i++) {
      if (i) q[R + 1] = q[R].nx(), R++;
      for (int j = 0; j < n - 1; j++) q[R + 1] = q[R].nz(), R++;
      q[R + 1] = q[R].nx(), R++;
      for (int j = 0; j < n - 1; j++) q[R + 1] = q[R].pz(), R++;
    }
    st[n] = L;
    q[L - 1] = q[L].pz(), L--;
    q[R + 1] = q[R].pz(), R++;
    for (int i = 0; i < n - 1; i++) q[R + 1] = q[R].px(), R++;
    for (int i = 0; i < n / 2; i++) {
      if (i) q[L - 1] = q[L].nx(), L--;
      for (int j = 0; j < n - 1; j++) q[L - 1] = q[L].py(), L--;
      q[L - 1] = q[L].nx(), L--;
      for (int j = 0; j < n - 1; j++) q[L - 1] = q[L].ny(), L--;
    }
    q[L - 1] = q[L].nx(), L--;
    for (int i = 0; i < n; i++) q[L - 1] = q[L].nz(), L--;
    for (int i = 0; i < n; i++) q[L - 1] = q[L].py(), L--;
    for (int i = 0; i < n / 2; i++) {
      q[L - 1] = q[L].pz(), L--;
      for (int j = 0; j < n - 1; j++) q[L - 1] = q[L].ny(), L--;
      q[L - 1] = q[L].pz(), L--;
      for (int j = 0; j < n - 1; j++) q[L - 1] = q[L].py(), L--;
    }
    q[R + 1] = q[R].px(), R++;
    for (int i = 0; i < n; i++) q[R + 1] = q[R].nz(), R++;
    for (int i = 0; i < n; i++) q[R + 1] = q[R].ny(), R++;
    for (int i = 0; i < n / 2; i++) {
      q[R + 1] = q[R].pz(), R++;
      for (int j = 0; j < n - 1; j++) q[R + 1] = q[R].py(), R++;
      q[R + 1] = q[R].pz(), R++;
      for (int j = 0; j < n - 1; j++) q[R + 1] = q[R].ny(), R++;
    }
    st[n + 1] = L;
  }
}
int mat[55][55][55];
int main() {
  pre();
  int n;
  gn(n);
  int m = n * n * n;
  int mnx = 0x3f3f3f3f, mny = 0x3f3f3f3f;
  for (int i = 0; i < m; i++) {
    smin(mnx, q[st[n] + i].first);
    smin(mny, q[st[n] + i].second);
  }
  for (int i = 0; i < m; i++) {
    mat[q[st[n] + i].first - mnx][q[st[n] + i].second - mny][q[st[n] + i].z] =
        i + 1;
  }
  for (int i = 0; i < n; i++, puts(""))
    for (int j = 0; j < n; j++, puts(""))
      for (int k = 0; k < n; k++) printsp(mat[i][j][k]);
  return 0;
}