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 T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 53;
int num[_][_][_];
int xh, yh, zh, ch;
int xt, yt, zt, ct;
int n;
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty();
  if (n == 1) {
    cout << 1 << lf;
    return 0;
  }
  memset(num, -2, sizeof(num));
  xh = 2, yh = 1, zh = 1, num[xh][yh][zh] = ch = 1;
  xt = 1, yt = 1, zt = 1, num[xt][yt][zt] = ct = 0;
  (num[xh][yh][++zh] = ++ch), (num[xh][++yh][zh] = ++ch),
      (num[xh][yh][--zh] = ++ch);
  (num[xt][++yt][zt] = --ct), (num[xt][yt][++zt] = --ct),
      (num[xt][--yt][zt] = --ct);
  for (int i = 2; i < n; i++) {
    if (i & 1) {
      (num[++xh][yh][zh] = ++ch);
      for (int j = 1; j < i; j++) (num[xh][yh][--zh] = ++ch);
      (num[xh][--yh][zh] = ++ch);
      for (int j = 1; j <= i; (num[xh][yh][++zh] = ++ch), j++)
        for (int k = 2; k < i; k++)
          (j & 1 ? (num[xh][--yh][zh] = ++ch) : (num[xh][++yh][zh] = ++ch));
      for (int j = 1; j <= i; (num[xh][++yh][zh] = ++ch), j++)
        for (int k = 1; k < i; k++)
          (j & 1 ? (num[--xh][yh][zh] = ++ch) : (num[++xh][yh][zh] = ++ch));
      for (int j = 1; j <= i; (j != i ? (num[++xh][yh][zh] = ++ch) : 0), j++)
        for (int k = 1; k <= i; k++)
          (j & 1 ? (num[xh][yh][--zh] = ++ch) : (num[xh][yh][++zh] = ++ch));
      (num[xt][++yt][zt] = --ct);
      for (int j = 1; j <= i; j++) (num[xt][yt][++zt] = --ct);
      for (int j = 1; j <= i; j++) (num[xt][--yt][zt] = --ct);
    } else {
      (num[++xh][yh][zh] = ++ch);
      for (int j = 1; j <= i; (num[xh][yh][++zh] = ++ch), j++)
        for (int k = 1; k < i; k++)
          (j & 1 ? (num[xh][--yh][zh] = ++ch) : (num[xh][++yh][zh] = ++ch));
      for (int j = 1; j <= i; (j != i ? (num[--xh][yh][zh] = ++ch) : 0), j++)
        for (int k = 1; k < i; k++)
          (j & 1 ? (num[xh][--yh][zh] = ++ch) : (num[xh][++yh][zh] = ++ch));
      (num[xh][++yh][zh] = ++ch);
      for (int j = 1; j <= i; (j != i ? (num[++xh][yh][zh] = ++ch) : 0), j++)
        for (int k = 1; k <= i; k++)
          (j & 1 ? (num[xh][yh][--zh] = ++ch) : (num[xh][yh][++zh] = ++ch));
      (num[xt][yt][++zt] = --ct);
      for (int j = 1; j <= i; j++) (num[xt][++yt][zt] = --ct);
      for (int j = 1; j <= i; j++) (num[xt][yt][--zt] = --ct);
    }
  }
  for (int i = 1; i <= n; i++, cout << lf)
    for (int j = 1; j <= n; j++, cout << lf)
      for (int k = 1; k <= n; k++) cout << num[i][j][k] - ct + 1 << ' ';
  return 0;
}