var n,i,k,j,x,y,q,p:longint;
a:array[1..1000,1..1000] of integer;
b,c:array[1..200000] of integer;
f,g:text;
begin
p:=0;
assign(f,'broscute.in');
reset(f);
readln(f,n,k);
for i:=1 to k do begin
readln(f,x,y);
a[x,y]:=1;
b[i]:=x;
c[i]:=y;
end;
close(f);
for q:=1 to k do begin

 begin
i:=b[q]+1; j:=c[q]+1 ;
while (i<=n) and(j<=n) do begin
a[i,j]:=a[i,j]+2;
i:=i+1; j:=j+1;
end;
i:=b[q]-1; j:=c[q]-1 ;
while (i>0) and (j>0) do begin
a[i,j]:=a[i,j]+2;
i:=i-1; j:=j-1;
end;
i:=b[q]-1; j:=c[q]+1 ;
while (i>0) and (j<=n) do begin
a[i,j]:=a[i,j]+2;
i:=i-1;  j:=j+1;
end;
i:=b[q]+1; j:=c[q]-1 ;
while (j>0) and (i<=n) do begin
a[i,j]:=a[i,j]+2;
i:=i+1; j:=j-1;
     end;
 end;
 end;

 for i:=1 to n do for j:=1 to n do if a[i,j]>=3 then p:=p+1;
 for i:=1 to n do begin
 for j:=1 to n do write(a[i,j],' ');
 writeln;
 end;
 assign(g,'broscute.out');
 rewrite(g);
 write(g,p);
 close(g);
 end.