#include <iostream>
#include <queue>
#include <cmath>
#define x first
#define y second
using namespace std;
const int N = 110;
typedef pair<int, int> pii;
int n, m, id;
double mp[N];
int top;
pii q[N * N];
char graph[N][N];
int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
double get_hash(){
double res = 0;
for(int i = 0; i < top; i ++ ){
for(int j = i + 1; j < top; j ++ ){
double xx = q[i].x - q[j].x;
double yy = q[i].y - q[j].y;
res += sqrt(xx * xx + yy * yy);
}
}
return res;
}
char get_id(double key){
for(int i = 0; i < id; i ++ ){
if(fabs(key - mp[i]) < 1e-6) return 'a' + i;
}
mp[id ++ ] = key;
return id - 1 + 'a';
}
void bfs(int i, int j){
queue<pii> qu;
qu.push({i, j}), q[top ++ ] = {i, j};
graph[i][j] = '@';
while(!qu.empty()){
pii now = qu.front();
qu.pop();
for(int i = 0; i < 8; i ++ ){
int xx = now.x + dx[i];
int yy = now.y + dy[i];
if(xx < 0 || xx >= n || yy < 0 || yy >= m || graph[xx][yy] != '1') continue;
graph[xx][yy] = '@';
qu.push({xx, yy}), q[top ++ ] = {xx, yy};
}
}
}
int main(){
cin >> m >> n;
for(int i = 0; i < n; i ++ ) cin >> graph[i];
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
if(graph[i][j] == '1'){
top = 0;
bfs(i, j);
char c = get_id(get_hash());
for(int k = 0 ; k < top; k ++ ) graph[q[k].x][q[k].y] = c;
}
}
}
for(int i = 0; i < n; i ++ ){
for(int j = 0; j < m; j ++ ){
cout << graph[i][j];
}
cout << endl;
}
return 0;
}