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>
using namespace std;
vector<vector<int> > Generate_odd(int n) {
  vector<vector<int> > answer(n);
  for (int i = 0; i < n; i++) answer[i].resize(n);
  for (int i = 0; i < n; i++) answer[i][i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int k = (i - j + n) % n;
      if (k != j) answer[j][k] = i + 1;
    }
  }
  return answer;
}
vector<vector<int> > Merge_odd(vector<vector<int> > &odd) {
  int n = odd.size() * 2;
  vector<vector<int> > answer(n);
  for (int i = 0; i < n; i++) answer[i].resize(n);
  for (int i = 0; i < n / 2; i++)
    for (int j = 0; j < n / 2; j++) {
      answer[i][j] = odd[i][j];
      answer[i + n / 2][j + n / 2] = odd[i][j];
    }
  for (int i = 0; i < n / 2; i++) {
    vector<bool> can_be(n / 2 + 1);
    for (int j = 0; j < can_be.size(); j++) can_be[j] = true;
    for (int j = 0; j < n / 2; j++) can_be[odd[i][j]] = false;
    for (int j = 0; j < can_be.size(); j++)
      if (can_be[j]) {
        answer[i][i + n / 2] = j;
        answer[i + n / 2][i] = j;
        break;
      }
  }
  for (int i = n / 2 + 1; i < n; i++)
    for (int j = 0; j < n / 2; j++) {
      int k = (i + j) % (n / 2) + n / 2;
      answer[j][k] = i;
      answer[k][j] = i;
    }
  return answer;
}
vector<vector<int> > Merge_even(vector<vector<int> > &even) {
  int n = even.size() * 2;
  vector<vector<int> > answer(n);
  for (int i = 0; i < n; i++) answer[i].resize(n);
  for (int i = 0; i < n / 2; i++)
    for (int j = 0; j < n / 2; j++) {
      answer[i][j] = even[i][j];
      answer[i + n / 2][j + n / 2] = even[i][j];
    }
  for (int i = n / 2; i < n; i++)
    for (int j = 0; j < n / 2; j++) {
      int k = (i + j) % (n / 2) + n / 2;
      answer[j][k] = i;
      answer[k][j] = i;
    }
  return answer;
}
vector<vector<int> > Solve(int n) {
  int power_of_2 = 0, odd_part;
  while (n % 2 == 0) {
    power_of_2++;
    n /= 2;
  }
  odd_part = n;
  vector<vector<int> > odd = Generate_odd(odd_part);
  vector<vector<int> > even = Merge_odd(odd);
  power_of_2--;
  for (int i = 0; i < power_of_2; i++) even = Merge_even(even);
  return even;
}
int main() {
  int n;
  cin >> n;
  vector<vector<int> > answer = Solve(n);
  for (int i = 0; i < answer.size(); i++) {
    for (int j = 0; j < answer[i].size(); j++) cout << answer[i][j] << ' ';
    cout << '\n';
  }
}