#include <bits/stdc++.h>
using namespace std;
int Ans[51][51][51];
void Solve(int N) {
  if (N == 1) {
    Ans[0][0][0] = 0;
    Ans[0][1][0] = 1;
    return;
  }
  Solve(N - 1);
  static int A[51][51][51];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++) A[i][j][k] = Ans[i][j][k];
  int Count = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (i & 1)
        Ans[i][0][N - 1 - j] = Count++;
      else
        Ans[i][0][j] = Count++;
  if (N & 1) {
    for (int i = 0; i < N - 1; i++)
      for (int j = 0; j < N; j++)
        for (int k = 0; k < N - 1; k++)
          Ans[N - 1 - k][i + 1][N - 1 - j] = A[i][j][k] + Count;
    Count += N * (N - 1) * (N - 1);
    for (int i = 1; i < N; i++)
      for (int j = 0; j < N; j++)
        if (i & 1)
          Ans[0][i][j] = Count++;
        else
          Ans[0][i][N - 1 - j] = Count++;
    for (int i = 0; i < N; i++) Ans[i][N][0] = Count++;
    for (int i = N - 1; i >= 0; i--)
      for (int j = 1; j < N; j++)
        if (~i & 1)
          Ans[i][N][j] = Count++;
        else
          Ans[i][N][N - j] = Count++;
  } else {
    for (int i = 0; i < N - 1; i++)
      for (int j = 0; j < N; j++)
        for (int k = 0; k < N - 1; k++)
          Ans[N - 1 - k][i + 1][j] = A[i][j][k] + Count;
    Count += N * (N - 1) * (N - 1);
    for (int i = 1; i < N; i++)
      for (int j = 0; j < N; j++)
        if (~i & 1)
          Ans[0][i][j] = Count++;
        else
          Ans[0][i][N - 1 - j] = Count++;
    for (int j = 0; j < N; j++)
      for (int i = 0; i < N; i++)
        if (~j & 1)
          Ans[i][N][j] = Count++;
        else
          Ans[N - 1 - i][N][j] = Count++;
  }
}
int main() {
  int N;
  scanf("%d", &N);
  Solve(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++) {
        printf("%d", Ans[i][j][k] + 1);
        putchar((k == N - 1) ? '\n' : ' ');
      }
    if (i + 1 < N) putchar('\n');
  }
  return 0;
}
