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;
const int NN = 52 * 52 * 52;
char q[NN << 1];
int ans[55][55][55];
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    puts("1");
    return 0;
  }
  if (n == 2) {
    puts("1 2");
    puts("4 3");
    puts("");
    puts("6 7");
    puts("5 8");
    return 0;
  }
  int st = NN, ed = NN;
  q[ed++] = 'D';
  q[ed++] = 'R';
  q[ed++] = 'U';
  q[ed++] = 'B';
  q[ed++] = 'D';
  q[ed++] = 'L';
  q[ed++] = 'U';
  q[ed++] = 'B';
  q[ed++] = 'D';
  q[ed++] = 'R';
  q[ed++] = 'U';
  for (int f = 3; f < n; f++) {
    q[--st] = 'D';
    q[ed++] = 'U';
    if (f & 1) {
      for (int ii = 0; ii < (f - 3); ii++) q[--st] = 'L';
      q[--st] = 'F';
      for (int i = 0; i < f - 2; i++) {
        if (i) q[--st] = 'R';
        if (i & 1)
          for (int ii = 0; ii < (f - 2); ii++) q[--st] = 'B';
        else
          for (int ii = 0; ii < (f - 2); ii++) q[--st] = 'F';
      }
      q[--st] = 'R';
      for (int i = 0; i < f; i++) {
        if (i) q[--st] = 'U';
        if (i & 1)
          for (int ii = 0; ii < (f - 2); ii++) q[--st] = 'F';
        else
          for (int ii = 0; ii < (f - 2); ii++) q[--st] = 'B';
      }
      q[--st] = 'B';
      for (int ii = 0; ii < (f - 1); ii++) q[--st] = 'D';
      for (int ii = 0; ii < (f - 1); ii++) q[ed++] = 'F';
      q[ed++] = 'R';
      for (int i = 0; i < f; i++) {
        if (i) q[ed++] = 'D';
        if (i & 1)
          for (int ii = 0; ii < (f - 2); ii++) q[ed++] = 'F';
        else
          for (int ii = 0; ii < (f - 2); ii++) q[ed++] = 'B';
      }
      q[ed++] = 'B';
      for (int ii = 0; ii < (f - 1); ii++) q[ed++] = 'U';
    } else {
      for (int i = 0; i < f; i++) {
        if (i) q[--st] = 'L';
        if (i & 1)
          for (int ii = 0; ii < (f - 3); ii++) q[--st] = 'B';
        else
          for (int ii = 0; ii < (f - 3); ii++) q[--st] = 'F';
      }
      q[--st] = 'B';
      for (int i = 0; i < f; i++) {
        if (i) q[--st] = 'R';
        if (i & 1)
          for (int ii = 0; ii < (f - 1); ii++) q[--st] = 'D';
        else
          for (int ii = 0; ii < (f - 1); ii++) q[--st] = 'U';
      }
      for (int ii = 0; ii < (f - 1); ii++) q[ed++] = 'L';
      q[ed++] = 'B';
      for (int i = 0; i < f; i++) {
        if (i) q[ed++] = 'R';
        if (i & 1)
          for (int ii = 0; ii < (f - 1); ii++) q[ed++] = 'U';
        else
          for (int ii = 0; ii < (f - 1); ii++) q[ed++] = 'D';
      }
    }
  }
  int x, y, z;
  q[--st] = 'D';
  if (n & 1) {
    for (int i = 0; i < n - 1; i++) {
      if (i) q[--st] = 'L';
      if (i & 1)
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'B';
      else
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'F';
    }
    q[--st] = 'L';
    for (int i = 0; i < n; i++) {
      if (i) q[--st] = 'U';
      if (i & 1)
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'B';
      else
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'F';
    }
  } else {
    for (int i = 0; i < n - 1; i++) {
      if (i) q[--st] = 'F';
      if (i & 1)
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'R';
      else
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'L';
    }
    q[--st] = 'F';
    for (int i = 0; i < n; i++) {
      if (i) q[--st] = 'U';
      if (i & 1)
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'L';
      else
        for (int ii = 0; ii < (n - 1); ii++) q[--st] = 'R';
    }
  }
  x = n;
  y = 1;
  z = n;
  int crr;
  ans[x][y][z] = crr = 1;
  for (int i = st; i < ed; i++) {
    if (q[i] == 'U') y++;
    if (q[i] == 'D') y--;
    if (q[i] == 'R') x++;
    if (q[i] == 'L') x--;
    if (q[i] == 'B') z++;
    if (q[i] == 'F') z--;
    ans[x][y][z] = ++crr;
  }
  for (int i = 1; i <= n; i++, puts("")) {
    for (int j = 1; j <= n; j++, puts("")) {
      for (int k = 1; k <= n; k++) {
        printf("%d ", ans[i][j][k]);
      }
    }
  }
  return 0;
}