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>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
int n, ans[101][101][101];
void output(bool o = 0) {
  int xl = 1000, xr = 0, yl = 1000, yr = 0, zl = 1000, zr = 0, L = 1e9, R = 0;
  for (int i = 0; i <= 100; ++i)
    for (int j = 0; j <= 100; ++j)
      for (int k = 0; k <= 100; ++k)
        if (ans[i][j][k]) {
          if (ans[i][j][k] < L) L = ans[i][j][k];
          if (ans[i][j][k] > R) R = ans[i][j][k];
          if (i < xl) xl = i;
          if (i > xr) xr = i;
          if (j < yl) yl = j;
          if (j > yr) yr = j;
          if (k < zl) zl = k;
          if (k > zr) zr = k;
        }
  if (o) {
    assert(n == xr - xl + 1);
    assert(n == yr - yl + 1);
    assert(n == zr - zl + 1);
    assert(n * n * n == R - L + 1);
  }
  for (int i = xl; i <= xr; ++i) {
    for (int j = yl; j <= yr; ++j) {
      for (int k = zl; k <= zr; ++k) printf("%d ", ans[i][j][k] - L + 1);
      puts("");
    }
    puts("");
  }
  fflush(stdout);
}
int main() {
  n = gi();
  if (n == 1) {
    puts("1");
    return 0;
  }
  if (n == 2) {
    puts("1 2\n4 3\n\n8 7\n5 6");
    return 0;
  }
  int hx = 50, hy = 50, hz = 50, h = 100000000, t = 100000000, tx = 50, ty = 50,
      tz = 50;
  ans[hx][hy][hz] = h;
  (assert(!ans[tx][ty][tz + 1]), ans[tx][ty][++tz] = ++t);
  (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
  (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
  (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
  (assert(!ans[tx][ty][tz + 1]), ans[tx][ty][++tz] = ++t);
  (assert(!ans[tx + 1][ty][tz]), ans[++tx][ty][tz] = ++t);
  (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
  (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
  (assert(!ans[tx][ty][tz + 1]), ans[tx][ty][++tz] = ++t);
  (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
  (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
  for (int s = 2; s < n; ++s)
    if (s & 1) {
      (assert(!ans[hx][hy][hz - 1]), ans[hx][hy][--hz] = --h),
          (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
      for (int j = 1; j <= s; ++j)
        (assert(!ans[hx - 1][hy][hz]), ans[--hx][hy][hz] = --h);
      for (int j = 1; j * 2 <= s + 1; ++j) {
        for (int k = 1; k < s - 1; ++k)
          (assert(!ans[tx][ty - 1][tz]), ans[tx][--ty][tz] = ++t);
        (assert(!ans[tx + 1][ty][tz]), ans[++tx][ty][tz] = ++t);
        for (int k = 1; k < s - 1; ++k)
          (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
        if (j * 2 < s + 1)
          (assert(!ans[tx + 1][ty][tz]), ans[++tx][ty][tz] = ++t);
      }
      (assert(!ans[hx][hy - 1][hz]), ans[hx][--hy][hz] = --h);
      for (int j = 1; j * 2 <= s + 1; ++j) {
        for (int k = 1; k <= s; ++k)
          (assert(!ans[hx][hy][hz + 1]), ans[hx][hy][++hz] = --h);
        (assert(!ans[hx + 1][hy][hz]), ans[++hx][hy][hz] = --h);
        for (int k = 1; k <= s; ++k)
          (assert(!ans[hx][hy][hz - 1]), ans[hx][hy][--hz] = --h);
        if (j * 2 < s + 1)
          (assert(!ans[hx + 1][hy][hz]), ans[++hx][hy][hz] = --h);
      }
      if (s + 1 < n) {
        (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
        for (int j = 1; j * 2 <= s + 1; ++j) {
          for (int k = 1; k <= s; ++k)
            (assert(!ans[tx][ty][tz + 1]), ans[tx][ty][++tz] = ++t);
          (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
          for (int k = 1; k <= s; ++k)
            (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
          if (j * 2 < s + 1)
            (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
        }
      }
    } else {
      (assert(!ans[hx][hy][hz - 1]), ans[hx][hy][--hz] = --h),
          (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
      for (int j = 1; j <= s; ++j)
        (assert(!ans[hx][hy + 1][hz]), ans[hx][++hy][hz] = --h);
      for (int j = 1; j < s - 1; ++j)
        (assert(!ans[tx + 1][ty][tz]), ans[++tx][ty][tz] = ++t);
      for (int j = 1; j <= s; ++j)
        (assert(!ans[tx][ty - 1][tz]), ans[tx][--ty][tz] = ++t);
      for (int j = 1; j * 2 < s; ++j) {
        (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
        for (int k = 1; k < s; ++k)
          (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
        (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
        for (int k = 1; k < s; ++k)
          (assert(!ans[tx][ty - 1][tz]), ans[tx][--ty][tz] = ++t);
      }
      (assert(!ans[hx + 1][hy][hz]), ans[++hx][hy][hz] = --h);
      for (int k = 1; k <= s; ++k)
        (assert(!ans[hx][hy][hz + 1]), ans[hx][hy][++hz] = --h);
      for (int k = 1; k <= s; ++k)
        (assert(!ans[hx][hy - 1][hz]), ans[hx][--hy][hz] = --h);
      for (int j = 1; j * 2 <= s; ++j) {
        (assert(!ans[hx][hy][hz - 1]), ans[hx][hy][--hz] = --h);
        for (int k = 1; k < s; ++k)
          (assert(!ans[hx][hy + 1][hz]), ans[hx][++hy][hz] = --h);
        (assert(!ans[hx][hy][hz - 1]), ans[hx][hy][--hz] = --h);
        for (int k = 1; k < s; ++k)
          (assert(!ans[hx][hy - 1][hz]), ans[hx][--hy][hz] = --h);
      }
      if (s + 1 < n) {
        (assert(!ans[tx - 1][ty][tz]), ans[--tx][ty][tz] = ++t);
        for (int k = 1; k <= s; ++k)
          (assert(!ans[tx][ty][tz + 1]), ans[tx][ty][++tz] = ++t);
        for (int k = 1; k <= s; ++k)
          (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
        for (int j = 1; j * 2 <= s; ++j) {
          (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
          for (int k = 1; k < s; ++k)
            (assert(!ans[tx][ty - 1][tz]), ans[tx][--ty][tz] = ++t);
          (assert(!ans[tx][ty][tz - 1]), ans[tx][ty][--tz] = ++t);
          for (int k = 1; k < s; ++k)
            (assert(!ans[tx][ty + 1][tz]), ans[tx][++ty][tz] = ++t);
        }
      }
    }
  output(1);
  return 0;
}