H=0...gets.to_i
W=0...gets.to_i
G=readlines
z=->x,y{(H===y&&W===x&&' '!=G[y][x])?1:0}
H.map{|j|W.map{|i|l=G[j][i]
G[j][i]="@V;#{l}>Fb#{l}<Yd#{l*5}"[z[i+1,j]*8+z[i-1,j]*4+z[i,j+1]*2+z[i,j-1]]if' '!=l}}
puts G
SD0wLi4uZ2V0cy50b19pClc9MC4uLmdldHMudG9faQpHPXJlYWRsaW5lcwp6PS0+eCx5eyhIPT09eSYmVz09PXgmJicgJyE9R1t5XVt4XSk/MTowfQpILm1hcHt8anxXLm1hcHt8aXxsPUdbal1baV0KR1tqXVtpXT0iQFY7I3tsfT5GYiN7bH08WWQje2wqNX0iW3pbaSsxLGpdKjgreltpLTEsal0qNCt6W2ksaisxXSoyK3pbaSxqLTFdXWlmJyAnIT1sfX0KcHV0cyBH
MTIKMTgKICAgeHggIHh4eCAgeHh4ICAgCiAgeHh4eCAgeHh4ICB4eHggIAogeHh4eHh4ICB4eHggIHh4eCAKeHh4ICB4eHggIHh4eCAgeHh4Cnh4eHggeHh4ICB4eHggIHh4eAogeHh4eHh4ICB4eHggIHh4eCAKICB4eHh4ICB4eHggIHh4eCAgCnggIHh4ICB4eHggIHh4eCAgeAp4eCAgICB4eHggIHh4eCAgeHgKeHh4ICB4eHggIHh4eCAgeHh4Cnh4eHggIHh4eCAgeHh4ICB4eAp4eHh4eCAgeHh4ICB4eHggIHg=
12
18
xx xxx xxx
xxxx xxx xxx
xxxxxx xxx xxx
xxx xxx xxx xxx
xxxx xxx xxx xxx
xxxxxx xxx xxx
xxxx xxx xxx
x xx xxx xxx x
xx xxx xxx xx
xxx xxx xxx xxx
xxxx xxx xxx xx
xxxxx xxx xxx x