1 var tile,size,k,i,x,y,j:longint;
2 a:array[-1..100,-1..100] of longint;
3 procedure try(tr,tc,dr,dc,size:longint);
4 var s,t:longint;
5 begin
6 if size=1 then
7 exit;
8 t:=tile;//L型牌的编号
9 inc(tile);
10 s:=size div 2;
11 if (dr<tr+s)and(dc<tc+s) then//查找是否在左上角,在,继续找
12 try(tr,tc,dr,dc,s)
13 else//不在,将右下角用L型牌覆盖,找该L型牌
14 begin
15 a[tr+s-1,tc+s-1]:=t;
16 try(tr,tc,tr+s-1,tc+s-1,s);
17 end;
18 if (dr<tr+s)and(dc>=tc+s) then//查找是否在右上角
19 try(tr,tc+s,dr,dc,s)
20 else//不在将左下角用L型牌覆盖
21 begin
22 a[tr+s-1,tc+s]:=t;
23 try(tr,tc+s,tr+s-1,tc+s,s);
24 end;
25 if (dr>=tr+s)and(dc<tc+s) then//查找是否在左下角
26 try(tr+s,tc,dr,dc,s)
27 else//不在将右上角用L型牌覆盖
28 begin
29 a[tr+s,tc+s-1]:=t;
30 try(tr+s,tc,tr+s,tc+s-1,s);
31 end;
32 if (dr>=tr+s)and(dc>=tc+s) then//查找是否在右下角
33 try(tr+s,tc+s,dr,dc,s)
34 else//不在将左上角用L型牌覆盖
35 begin
36 a[tr+s,tc+s]:=t;
37 try(tr+s,tc+s,tr+s,tc+s,s);
38 end;
39 end;
40 begin
41 readln(size);
42 readln(x,y);
43 tile:=1;
44 try(0,0,x,y,size);
45 for i:=0 to size-1 do
46 begin
47 for j:=0 to size-1 do
48 write(a[i,j]:3,' ');
49 writeln;
50 end;
51 end.