Problem: Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix should contain integers from 0 to n - 1, main diagonal should contain only zeroes and matrix should be symmetric. Moreover, all numbers in each row should be different. Magicians are very tired of the thinking process, so they ask you to write a program to find such matrix.

Input

The first line contains one integer n (2 ≤ n ≤ 1000), n is even.

Output

Output n lines with n numbers each — the required matrix. Separate numbers with spaces. If there are several solutions, output any.

Examples

Input

2


Output

0 1
1 0


Input

4


Output

0 1 3 2
1 0 2 3
3 2 0 1
2 3 1 0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
template <typename first>
inline first abs(const first& a) {
  return a < 0 ? -a : a;
}
template <typename first>
inline first sqr(const first& a) {
  return a * a;
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-9;
const int INF = 1000 * 1000 * 1000;
const int N = 1000 + 13;
int n;
int a[N][N];
int used[N], u;
void check() {
  for (int i = 0; i < int(n); i++) {
    u++;
    for (int j = 0; j < int(n); j++) {
      assert(a[i][j] >= 0 && a[i][j] < n);
      assert(a[i][j] == a[j][i] && used[a[i][j]] != u);
      used[a[i][j]] = u;
    }
  }
}
void fillEven(int idx) {
  for (int i = 0; i < int(idx); i++) {
    assert(a[i][idx - 1 - i] == -1);
    a[i][idx - 1 - i] = idx;
  }
  if (idx == n - 2) {
    assert(a[n - 2][n - 1] == -1 && a[n - 1][n - 2] == -1);
    a[n - 2][n - 1] = a[n - 1][n - 2] = idx;
    return;
  }
  int fin = (n - 2 - idx) / 2;
  for (int i = 0; i < int(fin); i++) {
    assert(a[idx + i][n - 2 - i] == -1 && a[n - 2 - i][idx + i] == -1);
    a[idx + i][n - 2 - i] = a[n - 2 - i][idx + i] = idx;
  }
  assert(a[n - 1][n / 2 - 1 + idx / 2] == -1 &&
         a[n / 2 - 1 + idx / 2][n - 1] == -1);
  a[n - 1][n / 2 - 1 + idx / 2] = a[n / 2 - 1 + idx / 2][n - 1] = idx;
}
void fillOdd(int idx) {
  for (int i = 0; i < int(idx); i++) {
    if (i == idx - 1 - i) continue;
    assert(a[i][idx - 1 - i] == -1);
    a[i][idx - 1 - i] = idx;
  }
  assert(a[idx / 2][n - 1] == -1 && a[n - 1][idx / 2] == -1);
  a[idx / 2][n - 1] = a[n - 1][idx / 2] = idx;
  for (int i = 0; i < int(n - 1 - idx); i++) {
    assert(a[idx + i][n - 2 - i] == -1);
    a[idx + i][n - 2 - i] = idx;
  }
}
int main() {
  cin >> n;
  memset(a, -1, sizeof(a));
  for (int i = 0; i < int(n); i++) {
    a[i][i] = 0;
    a[i][n - 1 - i] = 1;
  }
  for (int i = 2; i < n; i++)
    if (i & 1)
      fillOdd(i);
    else
      fillEven(i);
  check();
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(n); j++) printf("%d ", a[i][j]);
    puts("");
  }
  return 0;
}