rt
#include<bits/stdc++.h>
using namespace std;
int z[2050][2050];
int f[2050],N,x,y,s,i,j,top;
typedef pair<int,int> coor;
int fnd(coor m,coor n)
{
int d,a,b;
a=(m.first+n.first-1)/2;
b=(m.second+n.second-1)/2;
if (x<=a&&y<=b) d=1;
if (x>a&&y<=b) d=2;
if (x<=a&&y>b) d=3;
if (x>a&&y>b) d=4;
return d;
}
void army(coor m,coor n,int k,bool g)
{
top++;
if (k!=1) z[(m.first+n.first-1)/2][(m.second+n.second-1)/2]=top;
if (k!=2) z[(m.first+n.first+1)/2][(m.second+n.second-1)/2]=top;
if (k!=3) z[(m.first+n.first-1)/2][(m.second+n.second+1)/2]=top;
if (k!=4) z[(m.first+n.first+1)/2][(m.second+n.second+1)/2]=top;
if (n.first-m.first<3) return ;
int kk;
if (k==1){
if (g) {kk=fnd(m,make_pair((m.first+n.first-1)/2,(m.second+n.second-1)/2));army(m,make_pair((m.first+n.first-1)/2,(m.second+n.second-1)/2),kk,1);}
else army(m,make_pair((m.first+n.first-1)/2,(m.second+n.second-1)/2),1,0);
}
else army(m,make_pair((m.first+n.first-1)/2,(m.second+n.second-1)/2),4,0);
if (k==2){
if (g) {kk=fnd(make_pair((m.first+n.first+1)/2,m.second),make_pair(n.first,(m.second+n.second-1)/2));army(make_pair((m.first+n.first+1)/2,m.second),make_pair(n.first,(m.second+n.second-1)/2),kk,1);}
else army(make_pair((m.first+n.first+1)/2,m.second),make_pair(n.first,(m.second+n.second-1)/2),2,0);
}
else army(make_pair((m.first+n.first+1)/2,m.second),make_pair(n.first,(m.second+n.second-1)/2),3,0);
if (k==3){
if (g) {kk=fnd(make_pair(m.first,(m.second+n.second+1)/2),make_pair((m.first+n.first-1)/2,n.second));army(make_pair(m.first,(m.second+n.second+1)/2),make_pair((m.first+n.first-1)/2,n.second),kk,1);}
else army(make_pair(m.first,(m.second+n.second+1)/2),make_pair((m.first+n.first-1)/2,n.second),3,0);
}
else army(make_pair(m.first,(m.second+n.second+1)/2),make_pair((m.first+n.first-1)/2,n.second),2,0);
if (k==4){
if (g) {kk=fnd(make_pair((m.first+n.first+1)/2,(m.second+n.second+1)/2),n); army(make_pair((m.first+n.first+1)/2,(m.second+n.second+1)/2),n,kk,1);}
else army(make_pair((m.first+n.first+1)/2,(m.second+n.second+1)/2),n,4,0);
}
else army(make_pair((m.first+n.first+1)/2,(m.second+n.second+1)/2),n,1,0);
return ;
}
int main()
{
int aaa;
cin>>N>>x>>y;
s=pow(2,N);
coor l(x,y);
z[x][y]=-1;
if (x<=s/2&&y<=s/2) aaa=1;
if (x>s/2&&y<=s/2) aaa=2;
if (x<=s/2&&y>s/2) aaa=3;
if (x>s/2&&y>s/2) aaa=4;
army(make_pair(1,1),make_pair(s,s),aaa,1);
top=0;
for (i=1;i<=s;i++)
{
for (j=1;j<=s;j++)
{
if (f[z[i][j]]==0&&z[i][j]!=-1)
{
top++;
f[z[i][j]]=top;
}
z[i][j]=f[z[i][j]];
if (z[i][j]==-1) cout<<"0 ";
else cout<<z[i][j]<<" ";
}
cout<<endl;
}
return 0;
}