#include <bits/stdc++.h>
using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  string S[50];
  int x=0;
  for(int i = 0; i < H; i++){
    cin >> S;
  }//Sの配置完了
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '.'){
        if((0<i-1<H-1)&&(0<j-1<w-1)){
          if(S[i-1][j-1]=='#'){
          x++;
          }
        }
        if((0<i-1<H-1)&&(0<j<w-1)){
          if(S[i-1][j]=='#'){
          x++;
          }
        }
        if((0<i-1<H-1)&&(0<j+1<w-1)){
          if(S[i-1][j+1]=='#'){
          x++;
          }
        }
        if((0<i<H-1)&&(0<j-1<w-1)){
          if(S[i][j-1]=='#'){
          x++;
          }
        }
        if((0<i<H-1)&&(0<j+1<w-1)){
          if(S[i][j+1]=='#'){
          x++;
          }
        }
        if((0<i+1<H-1)&&(0<j-1<w-1)){
          if(S[i+1][j-1]=='#'){
          x++;
          }
        }
          if((0<i+1<H-1)&&(0<j<w-1)){
            if(S[i+1][j]=='#'){
          x++;
            }
        }
          if((0<i+1<H-1)&&(0<j+1<w-1)){
            if(S[i+1][j+1]=='#'){
          x++;
            }
        }
        S[i][j]='x';
      }
    }
  }
  cout << S << endl;
