#include <bits/stdc++.h>
using namespace std;
int main()
{
int a[1005][1005];
int m;
cin >> m;
int n = pow(2, m);
a[1][1] = 1;
for (int b = 2; b <= n; b *= 2)
{
int h = b / 2;
for (int i = 1; i <= h; i++)
{
for (int j = 1; j <= h; j++)
{
a[h + i][h + j] = a[i][j];
a[i][h + j] = a[h + i][j] = a[i][j] + h;
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
return 0;
}