#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,s;
int fx[10][2]={{},{1,0},{0,1},{-1,0},{0,-1},{-1,-1},{1,-1},{-1,1},{1,1}};
int nn[105][105];
struct dian
{
int a,b;
int t;
};
void bfs()
{
dian no,ne;
queue<dian>lj;
no.a=x,no.b=y,no.t=1;
lj.push(no);
for(int i=1;;i++)
{
if(lj.empty())
{
break;
}
no=lj.front();
lj.pop();
nn[no.a][no.b]=no.t;
s=max(s,no.t);
for(int j=1;j<=8;j++)
{
ne.t=no.t+1,ne.a=no.a+fx[j][0],ne.b=no.b+fx[j][1];
if(ne.a<1||ne.b<1||ne.a>n||ne.b>m||nn[ne.a][ne.b])
{
continue;
}
lj.push(ne);
}
}
}
int main()
{
cin>>m>>n>>x>>y;
char x;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>x;
nn[i][j]=(x=='*'?-1:0);
}
}
bfs();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cout<<nn[i][j]<<" ";
}
cout<<endl;
}
return 0;
}