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, const U &b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
  if (a < b) a = b;
}
template <class 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 T1, class T2>
inline void gn(T1 &x1, T2 &x2) {
  gn(x1), gn(x2);
}
template <class T1, class T2, class T3>
inline void gn(T1 &x1, T2 &x2, T3 &x3) {
  gn(x1, x2), gn(x3);
}
template <class 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 <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T1, class T2>
inline void print(T1 x1, T2 x2) {
  printsp(x1), println(x2);
}
template <class T1, class T2, class T3>
inline void print(T1 x1, T2 x2, T3 x3) {
  printsp(x1), printsp(x2), println(x3);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = (long long)a * a % m)
    if (b & 1) ans = (long long)ans * a % m;
  return ans;
}
struct point {
  int first, second, z, nxt;
  point(int first = 0, int second = 0, int z = 0, int nxt = 0)
      : first(first), second(second), z(z), nxt(nxt) {}
  point operator+(point a) {
    return point(first + a.first, second + a.second, z + a.z);
  }
};
vector<point> p;
int st, ed, cur;
int a[110][110][110];
int make(point a) {
  p.push_back(a);
  return ++cur;
}
void start(int first, int second, int z) {
  int u = make(p[st] + point(first, second, z));
  p[u].nxt = st;
  st = u;
}
void finish(int first, int second, int z) {
  int u = make(p[ed] + point(first, second, z));
  p[ed].nxt = u;
  ed = u;
}
int calc(int i) {
  if (i & 1) return 1;
  return -1;
}
void odd(int first) {
  start(0, 0, 1);
  for (int i = 0; i < first; i++) start(1, 0, 0);
  for (int i = 0; i < first + 1; i++) {
    if (i)
      finish(-1, 0, 0);
    else
      finish(0, 0, 1);
    int val = calc(i);
    for (int j = 0; j < first - 2; j++) finish(0, val, 0);
  }
  for (int i = 0; i < first + 1; i++) {
    if (i)
      start(-1, 0, 0);
    else
      start(0, -1, 0);
    int val = calc(i);
    for (int j = 0; j < first; j++) start(0, 0, val);
  }
  for (int i = 0; i < first + 1; i++) {
    if (i)
      finish(1, 0, 0);
    else
      finish(0, 1, 0);
    int val = calc(i);
    for (int j = 0; j < first; j++) finish(0, 0, val);
  }
}
void even(int first) {
  start(0, 0, 1);
  for (int i = 0; i < first; i++) start(0, 1, 0);
  for (int i = 0; i < first - 1; i++) {
    if (i)
      finish(-1, 0, 0);
    else
      finish(0, 0, 1);
    int val = calc(i);
    for (int j = 0; j < first - 1; j++) finish(0, val, 0);
  }
  finish(0, -1, 0);
  for (int i = 0; i < first - 1; i++) finish(1, 0, 0);
  for (int i = 0; i < first + 1; i++) {
    if (i)
      start(0, 0, -1);
    else
      start(-1, 0, 0);
    int val = calc(i);
    for (int j = 0; j < first - 1; j++) start(0, val, 0);
  }
  start(0, -1, 0);
  for (int i = 0; i < first; i++) start(0, 0, 1);
  for (int i = 0; i < first + 1; i++) {
    if (i) finish(0, 0, -1);
    int val = calc(i + 1);
    for (int j = 0; j < first - 1; j++) finish(0, val, 0);
  }
  finish(0, 1, 0);
  for (int i = 0; i < first; i++) finish(0, 0, 1);
}
int main() {
  int n;
  gn(n);
  if (n == 1) return puts("1");
  p.push_back(point()), finish(1, 0, 0), finish(0, 0, -1), finish(-1, 0, 0);
  finish(0, 1, 0), finish(1, 0, 0), finish(0, 0, 1), finish(-1, 0, 0);
  finish(0, 1, 0), finish(0, 0, -1), finish(1, 0, 0), finish(0, 0, 1);
  for (int i = 2; i < n; i++) {
    if (i & 1)
      odd(i);
    else
      even(i);
  }
  int N = n * n * n, u = st;
  for (int i = 1; i <= N; i++) {
    a[55 + p[u].first][55 + p[u].second][55 + p[u].z] = i;
    u = p[u].nxt;
  }
  for (int i = 0; i < 110; i++) {
    int flag = 0;
    for (int j = 0; j < 110; j++) {
      int ok = 0;
      for (int k = 0; k < 110; k++)
        if (a[i][j][k]) {
          printsp(a[i][j][k]);
          ok = 1;
        }
      if (ok) {
        puts("");
        flag = 1;
      }
    }
    if (flag) puts("");
  }
}