#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, x, y, z;
  string s, count="........";
  cin >> h >> w;
  y=(w+2)*(h+2)-1;
  for (int i=0, i<y, i++)
    s.at(i)='_';
  
  for (int i=0, i<h, i++) {
    for (int j=0, j<w, j++) {
      x=i+(w+2)*i+1+j;
      cin >> s.at(x);
    }
  }
  
  for (int i=0, i<y, i++) {
    if (s.at(i)=='.') {
      z=0
      count.at(0) = s.at(i-w+1);
      count.at(1) = s.at(i-w+2);
      count.at(2) = s.at(i-w+3);
      count.at(3) = s.at(i-1);
      count.at(4) = s.at(i+1);
      count.at(5) = s.at(i+w+1);
      count.at(6) = s.at(i+w+2);
      count.at(7) = s.at(i+w+3);
      for (int j=0, j<8, j++) {
        if (s.at(j)=='#')
          z++;
      }
      s.(at(i)='z';
    }
  }

  for (int i=0, i<h, i++) {
    for (int j=0, j<w, j++) {
      x=i+(w+2)*i+1+j;
      cout << s.at(x);
    }
    cout << endl;
  }

}