#include<bits/stdc++.h>
using namespace std;
int aab();
int n, i;
int main()
{
while (cin >> n)
{
aab();
}
}
int aab()
{
if (n<=100)
{
int* nums = new int[n];
for (int i = 1; i <= n; i++) {
nums[i - 1] = i;
}
for (int t = 0; t < n; t++) {
for (int i = t; i < (n + t); i++) {
if (i >= n) {
cout << " " <<nums[i % n];
}
else if (i<n)
cout << " "<<nums[i];
}
cout << endl;
}
return 0;
}
}