var m,n,i,j,s,g,b,flagi,flagj,a1,a2,min,max,ni,nj,xi,xj:longint; a:array[1..105,1..105] of char; begin readln(m,n); for i:=1 to m do begin for j:=1 to n do read(a[i,j]); readln; end; for i:=1 to m do begin for j:=1 to n do if a[i,j]='*' then write('*') else begin s:=0; if a[i,j+1]='*' then inc(s); if a[i,j-1]='*' then inc(s); if a[i+1,j+1]='*' then inc(s); if a[i-1,j+1]='*' then inc(s); if a[i+1,j-1]='*' then inc(s); if a[i-1,j-1]='*' then inc(s); if a[i+1,j]='*' then inc(s); if a[i-1,j]='*' then inc(s); write(s); end; writeln; end; end. /************************************************************** Problem: 1580 User: admin Language: Pascal Result: Wrong Answer ****************************************************************/