//P16
#include<iostream>
#include<math.h>
using namespace std;
int map[40][40];
int main()
{
int n;
while (cin >> n)
{
map[1][1] = 1;
for (int k = 1; k <= n; k++)
{
int tmp = pow(2.0, k - 1);
for (int i = 1; i <= tmp; i++)
{
for (int j = 1; j <= tmp; j++)
{
map[i][tmp + j] = map[i][j] + tmp;
map[tmp + i][j] = map[i][j] + tmp;
map[tmp + i][tmp + j] = map[i][j];
}
}
}
n = pow(2.0, n);
int j;
for (int i = 1; i <= n; i++)
{
for (j = 1; j < n; j++)
printf("%d ", map[i][j]);
printf("%d\n", map[i][j]);
}
}
return 0;
}