program Minesweeper; uses crt; var infile,outfile:text; n, m: integer; x, y: integer; field: array[0..101,0..101] of char; row:array['a'..'e'] of integer; col:array['a'..'e'] of integer; c:char; bombcounter:integer; begin assign(infile,'DATA21.txt'); reset(infile); assign(outfile,'OUT21.txt'); rewrite(outfile); for x:=0 to 101 do for y:=0 to 101 do field[x,y]:='Z'; readln(infile,n,m); for x:=1 to n do begin for y:= 1 to m do begin read(infile,field[x,y]); case field[x,y] of 'a':begin row['a']:=x; col['a']:=y; end; 'b':begin row['b']:=x; col['b']:=y; end; 'c':begin row['c']:=x; col['c']:=y; end; 'd':begin row['d']:=x; col['d']:=y; end; 'e':begin row['e']:=x; col['e']:=y; end; end; end; readln(infile); end; for c:='a' to 'e' do begin bombcounter:=0; if field[row[c]-1,col[c]-1]='*' then inc(bombcounter); if field[row[c]-1,col[c]]='*' then inc(bombcounter); if field[row[c]-1,col[c]+1]='*' then inc(bombcounter); if field[row[c],col[c]-1]='*' then inc(bombcounter); if field[row[c],col[c]+1]='*' then inc(bombcounter); if field[row[c]+1,col[c]-1]='*' then inc(bombcounter); if field[row[c]+1,col[c]]='*' then inc(bombcounter); if field[row[c]+1,col[c]+1]='*' then inc(bombcounter); writeln(outfile,c,'-',bombcounter); end; close(infile); close(outfile); end.