var n,m,i,j:longint; a:array[0..101,0..101] of longint; b:array[0..101,0..101] of boolean; c:char; begin //assign(input,'mine.in'); //assign(output,'mine.out'); //reset(input); //rewrite(output); readln(n,m); fillchar(b,sizeof(b),false); for i:=1 to n do begin for j:=1 to m do begin read(c); if c='*' then b[i,j]:=true else if c='?' then b[i,j]:=false; end; readln; end; for i:=1 to n do begin for j:=1 to m do if b[i,j] then write('*') else begin a[i,j]:=0; if b[i-1,j-1] then inc(a[i,j]); if b[i-1,j] then inc(a[i,j]); if b[i-1,j+1] then inc(a[i,j]); if b[i,j-1] then inc(a[i,j]); if b[i,j+1] then inc(a[i,j]); if b[i+1,j-1] then inc(a[i,j]); if b[i+1,j] then inc(a[i,j]); if b[i+1,j+1] then inc(a[i,j]); write(a[i,j]); end; writeln; end; //close(input); //close(output); end. /************************************************************** Problem: 2341 User: admin Language: Pascal Result: Wrong Answer ****************************************************************/