var a:array[1..100,1..100]of integer;
i,j,c,b,n,k:integer;
begin
readln(n);
readln(c,b);
for i:=1 to n do for j:=1 to n do a[i,j]:=random(9)+1;
for i:=1 to n do begin for j:=1 to n do write(a[i,j],' '); if j=n then writeln; end;
writeln;
for i:=1 to n do
for j:=1 to n do
if (i>n-j+1) or (j=b) then inc(k);
writeln(k);
end.