#include<bits/stdc++.h>
using namespace std;
int b[500][500];
int tile = 1;
void TileBoard(int Start_x, int Start_y, int x, int y, int Size)
{
if(Size==1)
return;
int t = tile++;
int s = Size/2;
if (x<Start_x+s && y<Start_y+s) ///top-left
TileBoard(Start_x, Start_y, x, y, s);
else
{
b[Start_x+s-1][Start_y+s-1] = t;
TileBoard(Start_x, Start_y, Start_x+s-1, Start_y+s-1, s);
}
if (x<Start_x+s && y>=Start_y+s) ///top-right
TileBoard(Start_x, Start_y+s, x, y, s);
else
{
b[Start_x+s-1][Start_y+s] = t;
TileBoard(Start_x, Start_y+s, Start_x+s-1, Start_y+s, s);
}
if (x>=Start_x+s && y<Start_y+s) ///bottom-left
TileBoard(Start_x+s, Start_y, x, y, s);
else
{
b[Start_x+s][Start_y+s-1] = t;
TileBoard(Start_x+s, Start_y, Start_x+s, Start_y+s-1, s);
}
if (x>=Start_x+s && y>=Start_y+s) ///bottom-right
TileBoard(Start_x+s, Start_y+s, x, y, s);
else
{
b[Start_x+s][Start_y+s] = t;
TileBoard(Start_x+s, Start_y+s, Start_x+s, Start_y+s, s);
}
}
int main()
{
int n, x, y;
cin>>n>>x>>y;
TileBoard(1, 1, x, y, n); ///Let,Start point is (1,1)
b[x][y] = -1; ///Let,defect point is -1
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
cout<<setw(3)<<b[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGJbNTAwXVs1MDBdOwppbnQgdGlsZSA9IDE7Cgp2b2lkIFRpbGVCb2FyZChpbnQgU3RhcnRfeCwgaW50IFN0YXJ0X3ksIGludCB4LCBpbnQgeSwgaW50IFNpemUpCnsKICAgIGlmKFNpemU9PTEpCiAgICAgICAgcmV0dXJuOwogICAgaW50IHQgPSB0aWxlKys7CiAgICBpbnQgcyA9IFNpemUvMjsKCiAgICBpZiAoeDxTdGFydF94K3MgJiYgeTxTdGFydF95K3MpICAvLy90b3AtbGVmdAogICAgICAgIFRpbGVCb2FyZChTdGFydF94LCBTdGFydF95LCB4LCB5LCBzKTsKICAgIGVsc2UKICAgIHsKICAgICAgICBiW1N0YXJ0X3grcy0xXVtTdGFydF95K3MtMV0gPSB0OwogICAgICAgIFRpbGVCb2FyZChTdGFydF94LCBTdGFydF95LCBTdGFydF94K3MtMSwgU3RhcnRfeStzLTEsIHMpOwogICAgfQoKICAgIGlmICh4PFN0YXJ0X3grcyAmJiB5Pj1TdGFydF95K3MpICAvLy90b3AtcmlnaHQKICAgICAgICBUaWxlQm9hcmQoU3RhcnRfeCwgU3RhcnRfeStzLCB4LCB5LCBzKTsKICAgIGVsc2UKICAgIHsKICAgICAgICBiW1N0YXJ0X3grcy0xXVtTdGFydF95K3NdID0gdDsKICAgICAgICBUaWxlQm9hcmQoU3RhcnRfeCwgU3RhcnRfeStzLCBTdGFydF94K3MtMSwgU3RhcnRfeStzLCBzKTsKICAgIH0KCiAgICBpZiAoeD49U3RhcnRfeCtzICYmIHk8U3RhcnRfeStzKSAgLy8vYm90dG9tLWxlZnQKICAgICAgICBUaWxlQm9hcmQoU3RhcnRfeCtzLCBTdGFydF95LCB4LCB5LCBzKTsKICAgIGVsc2UKICAgIHsKICAgICAgICBiW1N0YXJ0X3grc11bU3RhcnRfeStzLTFdID0gdDsKICAgICAgICBUaWxlQm9hcmQoU3RhcnRfeCtzLCBTdGFydF95LCBTdGFydF94K3MsIFN0YXJ0X3krcy0xLCBzKTsKICAgIH0KCiAgICBpZiAoeD49U3RhcnRfeCtzICYmIHk+PVN0YXJ0X3krcykgIC8vL2JvdHRvbS1yaWdodAogICAgICAgIFRpbGVCb2FyZChTdGFydF94K3MsIFN0YXJ0X3krcywgeCwgeSwgcyk7CiAgICBlbHNlCiAgICB7CiAgICAgICAgYltTdGFydF94K3NdW1N0YXJ0X3krc10gPSB0OwogICAgICAgIFRpbGVCb2FyZChTdGFydF94K3MsIFN0YXJ0X3krcywgU3RhcnRfeCtzLCBTdGFydF95K3MsIHMpOwogICAgfQp9CgppbnQgbWFpbigpCnsKICAgIGludCBuLCB4LCB5OwogICAgY2luPj5uPj54Pj55OwogICAgVGlsZUJvYXJkKDEsIDEsIHgsIHksIG4pOyAvLy9MZXQsU3RhcnQgcG9pbnQgaXMgKDEsMSkKICAgIGJbeF1beV0gPSAtMTsgLy8vTGV0LGRlZmVjdCBwb2ludCBpcyAtMQogICAgZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspCiAgICB7CiAgICAgICAgZm9yKGludCBqID0gMTsgaiA8PSBuOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBjb3V0PDxzZXR3KDMpPDxiW2ldW2pdPDwiICI7CiAgICAgICAgfQogICAgICAgIGNvdXQ8PGVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=