/*
题意:给你一个n*m的地图,'.'代表空位,'*'墙壁,现在要让所有的空间都是矩形的,需要最少破坏多少个墙壁,
输出完成后的地图
类型:DFS
分析:从2*2的地图着手
*/
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
const int maxn = 2005;
char Map[maxn][maxn];
int n,m;
bool Judge(int x,int y){
if(x>=0&&x<n&&y>=0&&y<m)return true;
return false;
}
bool culnum(int x,int y){
if(Judge(x-1,y-1)&&Map[x-1][y-1]=='.'&&Map[x-1][y]=='.'&&Map[x][y-1]=='.')return true;
if(Judge(x-1,y+1)&&Map[x-1][y+1]=='.'&&Map[x-1][y]=='.'&&Map[x][y+1]=='.')return true;
if(Judge(x+1,y-1)&&Map[x+1][y-1]=='.'&&Map[x][y-1]=='.'&&Map[x+1][y]=='.')return true;
if(Judge(x+1,y+1)&&Map[x+1][y+1]=='.'&&Map[x+1][y]=='.'&&Map[x][y+1]=='.')return true;
return false;
}
void DFS(int x,int y){
for(int i=-1;i<=1;i++){
for(int j=-1;j<=1;j++){
int tx=x+i;
int ty=y+j;
if(Judge(tx,ty)&&Map[tx][ty]=='*'&&culnum(tx,ty)){
Map[tx][ty]='.';
DFS(tx,ty);
}
}
}
}
int main()
{
cin>>n>>m;
for(int i=0;i<n;i++){
scanf("%s",Map[i]);
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(Map[i][j]=='*'){
if(culnum(i,j)){
Map[i][j]='.';
DFS(i,j);
}
}
}
}
for(int i=0;i<n;i++){
printf("%s\n",Map[i]);
}
return 0;
}
/*
3 6
**.**.
*.*..*
****..
*/