//g++ -std=c++11 -O2 -Wall microwave.cpp -o microwave
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
//COMMENCE CODE
int gayarray[111][111];
for(int x = 1; x <= 104; x++)
{
if(x % 4 == 0)
{
int i = 1;
for(int y = x; y <= 104;)
{
gayarray[x][y] = i;
gayarray[y][x] = i;
i++;
gayarray[x][y-1] = i;
gayarray[y-1][x] = i;
i++;
gayarray[x][y-2] = i;
gayarray[y-2][x] = i;
i++;
gayarray[x][y-3] = i;
gayarray[y-3][x] = i;
i++;
y += 4;
}
}
else if(x % 3 == 0)
{
int i = 1;
for(int y = x; y <= 103;)
{
gayarray[x][y] = i;
gayarray[y][x] = i;
i++;
gayarray[x][y+1] = i;
gayarray[y+1][x] = i;
i++;
gayarray[x][y-2] = i;
gayarray[y-2][x] = i;
i++;
gayarray[x][y-1] = i;
gayarray[y-1][x] = i;
i++;
y += 4;
}
}
else if(x % 2 == 0)
{
int i = 1;
for(int y = x; y <= 102;)
{
gayarray[x][y] = i;
gayarray[y][x] = i;
i++;
gayarray[x][y-1] = i;
gayarray[y-1][x] = i;
i++;
gayarray[x][y+2] = i;
gayarray[y+2][x] = i;
i++;
gayarray[x][y+1] = i;
gayarray[y+1][x] = i;
i++;
y += 4;
}
}
else
{
int i = 1;
for(int y = x; y <= 109;)
{
gayarray[x][y] = i;
gayarray[y][x] = i;
y++;
i++;
}
}
}
//Ask table size
int n;
cin >> n;
//print
for(int y = 1; y <= n; y++)
{
for(int x = 1; x <= n; x++)
{
printf("%d", gayarray[x][y]);
if(x != n)
{
printf(" ");
}
}
if(y != n)
{
printf("\n");
}
}
}