#include<iostream>
#include<cmath>
#include <memory.h>
using namespace std;
int matrix[512][512];
int mark = 0;
void generator(int beginx, int beginy, int endx, int endy, int x2, int y2) {
int order = endx - beginx + 1;
int positions[4][2] = { {order / 2 - 1 + beginx, order / 2 - 1 + beginy}, {order / 2 - 1 + beginx, order / 2 + beginy}, {order / 2 + beginx, order / 2 + beginy}, {order / 2 + beginx, order / 2 - 1 + beginy} };
int min = abs(positions[0][0] - x2) + abs(positions[0][1] - y2), positionMin = 0;
for (int i = 1; i < 4; i++) {
int length = abs(positions[i][0] - x2) + abs(positions[i][1] - y2);
positionMin = min < length ? positionMin : i;
min = min < length ? min : length;
}
mark++;
for (int i = 0; i < 4; i++) {
if (i == positionMin) continue;
else matrix[positions[i][0]][positions[i][1]] = mark;
}
if (order == 2) return;
if (positionMin == 0)generator(beginx, beginy, positions[0][0], positions[0][1], x2 , y2);
else generator(beginx, beginy, positions[0][0], positions[0][1], positions[0][0], positions[0][1]);
if (positionMin == 1)generator(beginx, positions[1][1], positions[1][0], endy, x2, y2);
else generator(beginx, positions[1][1], positions[1][0], endy, positions[1][0], positions[1][1]);
if (positionMin == 2)generator(positions[2][0], positions[2][1], endx, endy, x2, y2);
else generator(positions[2][0], positions[2][1], endx, endy, positions[2][0], positions[2][1]);
if (positionMin == 3)generator(positions[3][0], beginy, endx, positions[3][1], x2, y2);
else generator(positions[3][0], beginy, endx, positions[3][1], positions[3][0], positions[3][1]);
}
int main()
{
int n, x, y, n2;
cin >> n;
cin >> x;
cin >> y;
n2 = pow(2, n);
matrix[x - 1][y - 1] = 0;
generator(0, 0, n2 - 1, n2 - 1, x - 1, y - 1);
for (int i = 0; i < n2; i++)
{
for (int j = 0; j < n2 - 1; j++) cout << matrix[i][j] << " ";
cout << matrix[i][n2 - 1] << endl;
}
}