#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define MN 2001
char grid[MN][MN];
int visited[MN][MN];
int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}, dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<pair<int, int> > que;
            que.push({i,j});
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();

                for(int k=0;k<8;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.' && k < 4) {
                        visited[ny][nx] = 1;
                        que.push({ny, nx});
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(!isCan(ny+ay, nx+ax)) continue;
                            if(!isCan(ny+by, nx+bx)) continue;
                            if(!isCan(ny+cy, nx+cx)) continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push({ny, nx});

                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
#define MN 2002
char grid[MN][MN];
int visited[MN][MN];
int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}, dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<pair<int, int> > que;
            que.push({i,j});
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();

                for(int k=0;k<8;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.') {
                        if(k<4) {
                            visited[ny][nx] = 1;
                            que.push({ny, nx});
                        }
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(!isCan(ny+ay, nx+ax)) continue;
                            if(!isCan(ny+by, nx+bx)) continue;
                            if(!isCan(ny+cy, nx+cx)) continue;
                            if(visited[ny][nx]) continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push({ny, nx});

                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
#define MN 2002
char grid[MN][MN];
int visited[MN][MN];
int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}, dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M;

inline bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<pair<int, int> > que;
            que.push({i,j});
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();

                for(int k=0;k<8;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.' && k < 4) {
                        visited[ny][nx] = 1;
                        que.push({ny, nx});
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(ny+ay < 1 || ny+ay > N || nx+ax < 1 ||  nx+ax > M) continue;
                            if(grid[ny+ay][nx+ax] != '.') continue;

                            if(ny+by < 1 || ny+by > N || nx+bx < 1 ||  nx+bx > M) continue;
                            if(grid[ny+by][nx+bx] != '.') continue;

                            if(ny+cy < 1 || ny+cy > N || nx+cx < 1 ||  nx+cx > M) continue;
                            if(grid[ny+cy][nx+cx] != '.') continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push({ny, nx});

                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <string>
#include <queue>
#include <memory.h>
using namespace std;
#define MN 2001
char grid[MN][MN];
int visited[MN][MN];
int dy[4] = {-1, 0, 1, 0}, dx[4] = {0, 1, 0, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            if(grid[i][j] == '*') continue;
            memset(visited, 0, sizeof(visited));

            queue<pair<int, int> > que;
            que.push({i,j});
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();

                for(int k=0;k<4;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;
                    visited[ny][nx] = 1;

                    if(grid[ny][nx] == '.') {
                        que.push({ny, nx});
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(!isCan(ny+ay, nx+ax)) continue;
                            if(!isCan(ny+by, nx+bx)) continue;
                            if(!isCan(ny+cy, nx+cx)) continue;

                            grid[ny][nx] = '.';
                            que.push({ny, nx});
                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
#define MN 2002
char grid[MN][MN];
int visited[MN][MN];
int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}, dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<int> que;
            que.push(i*MN+j);
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front()/MN;
                int x = que.front()%MN;
                que.pop();

                for(int k=0;k<8;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.') {
                        if(k<4) {
                            visited[ny][nx] = 1;
                            que.push(ny*MN+nx);
                        }
                    } else {
                        for(int p=0;p<4;p++) {
                            int cy = ny+dy[p%4]+dy[(p+1)%4];
                            int cx = nx+dx[p%4]+dx[(p+1)%4];

                            if(cy < 1 || cy > N || cx < 1 || cx > M) continue;
                            if(grid[cy][cx] != '.') continue;
                            if(grid[cy][nx] != '.') continue;
                            if(grid[ny][cx] != '.') continue;

                            if(visited[ny][nx]) continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push(ny*MN+nx);

                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define MN 2001
char grid[MN][MN];
int visited[MN][MN];
int dy[4] = {-1, 0, 1, 0}, dx[4] = {0, 1, 0, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=N;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<pair<int, int> > que;
            que.push({i,j});
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();

                for(int k=0;k<4;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.') {
                        visited[ny][nx] = 1;
                        que.push({ny, nx});
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(!isCan(ny+ay, nx+ax)) continue;
                            if(!isCan(ny+by, nx+bx)) continue;
                            if(!isCan(ny+cy, nx+cx)) continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push({ny, nx});
                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define MN 2001
char grid[MN][MN];
int visited[MN][MN];
int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}, dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<pair<int, int> > que;
            que.push({i,j});
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();

                for(int k=0;k<8;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.' && k < 4) {
                        visited[ny][nx] = 1;
                        que.push({ny, nx});
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(!isCan(ny+ay, nx+ax)) continue;
                            if(!isCan(ny+by, nx+bx)) continue;
                            if(!isCan(ny+cy, nx+cx)) continue;
                            if(visited[ny][nx]) continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push({ny, nx});

                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
#define MN 2002
char grid[MN][MN];
int visited[MN][MN];
int dy[8] = {-1, 0, 1, 0, -1, 1, -1, 1}, dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M;

bool isCan(int y, int x) {
    if(y < 1 || y > N || x < 1 || x > M) return false;
    if(grid[y][x] != '.') return false;
    return true;
}

int main () {
    scanf("%d%d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%s", grid[i]+1);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) {
            if(grid[i][j] == '*') continue;
            if(visited[i][j]) continue;

            queue<int> que;
            que.push(i*MN+j);
            visited[i][j] = 1;

            while(!que.empty()) {
                int y = que.front()/MN;
                int x = que.front()%MN;
                que.pop();

                for(int k=0;k<8;k++) {
                    int ny = y+dy[k];
                    int nx = x+dx[k];

                    if(ny < 1 || ny > N || nx < 1 || nx > M) continue;
                    if(visited[ny][nx]) continue;

                    if(grid[ny][nx] == '.') {
                        if(k<4) {
                            visited[ny][nx] = 1;
                            que.push(ny*MN+nx);
                        }
                    } else {
                        for(int p=0;p<4;p++) {
                            int ay = dy[p%4];
                            int ax = dx[p%4];

                            int by = dy[(p+1)%4];
                            int bx = dx[(p+1)%4];

                            int cy = ay+by;
                            int cx = ax+bx;

                            if(!isCan(ny+ay, nx+ax)) continue;
                            if(!isCan(ny+by, nx+bx)) continue;
                            if(!isCan(ny+cy, nx+cx)) continue;
                            if(visited[ny][nx]) continue;

                            visited[ny][nx] = 1;
                            grid[ny][nx] = '.';
                            que.push(ny*MN+nx);

                            break;
                        }
                    }
                }
            }
        }
    }

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) printf("%c", grid[i][j]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;

int n, m;
vector<int> di = {0,0,1,-1};
vector<int> dj = {1,-1,0,0};
vector<string> grid;
bool visited[2010][2010] = {0};

bool bounds(int i, int j) {
    if(i < 0) return false;
    if(j < 0) return false;
    if(i >= n) return false;
    if(j >= m) return false;
    return true;
}

int maxI, maxJ, minI, minJ;

void dfs(int i, int j) {
    maxI = max(maxI, i);
    minI = min(minI, i);
    maxJ = max(maxJ, j);
    minJ = min(minJ, j);
    visited[i][j] = true;
    for(int k = 0; k < 4; ++k) {
        const int toI = i+di[k];
        const int toJ = j+dj[k];
        if(!bounds(toI, toJ)) continue;
        if(visited[toI][toJ]) continue;
        if(grid[toI][toJ] == '*') continue;
        dfs(toI, toJ);
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    vector<set<int>> walls(n);
    grid.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> grid[i];
        for(int j = 0; j < m; ++j) {
            if(grid[i][j] == '*') {
                walls[i].insert(j);
            }
        }
    }
    bool found = true;
    while(found) {
        found = false;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                visited[i][j] = false;
            }
        }
        vector<pair<int, int>> places;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                if(visited[i][j]) continue;
                if(grid[i][j] == '*') continue;
                maxI = maxJ = -1;
                minI = minJ = n+m;
                dfs(i, j);
                for(int k = minI; k <= maxI; ++k) {
                    while(true) {
                        auto it = walls[k].lower_bound(minJ);
                        if(it == walls[k].end()) break;
                        if(*it > maxJ) break;
                        found = true;
                        places.push_back({k, *it});
                        walls[k].erase(it);
                    }
                }
            }
        }
        for(auto &p : places) grid[p.first][p.second] = '.';
    }
    for(int i = 0; i < n; ++i) {
        cout << grid[i] << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;

int n, m;
vector<int> di = {0,0,1,-1};
vector<int> dj = {1,-1,0,0};
vector<string> grid;
bool visited[2010][2010] = {0};

bool bounds(int i, int j) {
    if(i < 0) return false;
    if(j < 0) return false;
    if(i >= n) return false;
    if(j >= m) return false;
    return true;
}

int maxI, maxJ, minI, minJ;

void dfs(int i, int j) {
    maxI = max(maxI, i);
    minI = min(minI, i);
    maxJ = max(maxJ, j);
    minJ = min(minJ, j);
    visited[i][j] = true;
    for(int k = 0; k < 4; ++k) {
        const int toI = i+di[k];
        const int toJ = j+dj[k];
        if(!bounds(toI, toJ)) continue;
        if(visited[toI][toJ]) continue;
        if(grid[toI][toJ] == '*') continue;
        dfs(toI, toJ);
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    vector<set<int>> wallsRow(n);
    vector<set<int>> wallsCol(m);
    grid.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> grid[i];
        for(int j = 0; j < m; ++j) {
            if(grid[i][j] == '*') {
                wallsRow[i].insert(j);
                wallsCol[j].insert(i);
            }
        }
    }
    bool found = true;
    while(found) {
        found = false;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                visited[i][j] = false;
            }
        }
        vector<pair<int, int>> places;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                if(visited[i][j]) continue;
                if(grid[i][j] == '*') continue;
                maxI = maxJ = -1;
                minI = minJ = n+m;
                dfs(i, j);
                if(maxI-minI < maxJ-minJ) {
                    for(int k = minI; k <= maxI; ++k) {
                        while(true) {
                            auto it = wallsRow[k].lower_bound(minJ);
                            if(it == wallsRow[k].end()) break;
                            if(*it > maxJ) break;
                            found = true;
                            places.push_back({k, *it});
                            wallsCol[*it].erase(k);
                            wallsRow[k].erase(it);
                        }
                    }
                } else {
                    for(int k = minJ; k <= maxJ; ++k) {
                        while(true) {
                            auto it = wallsCol[k].lower_bound(minI);
                            if(it == wallsCol[k].end()) break;
                            if(*it > maxI) break;
                            places.push_back({*it, k});
                            wallsRow[*it].erase(k);
                            wallsCol[k].erase(it);
                        }
                    }
                }
            }
        }
        for(auto &p : places) grid[p.first][p.second] = '.';
    }
    for(int i = 0; i < n; ++i) {
        cout << grid[i] << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;

int n, m;
vector<string> grid;

bool bounds(int i, int j) {
    if(i < 0) return false;
    if(j < 0) return false;
    if(i >= n) return false;
    if(j >= m) return false;
    return true;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    grid.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> grid[i];
    }
    vector<int> dirsI = {0,0,1,1};
    vector<int> dirsJ = {0,1,0,1};
    queue<pair<int, int>> q;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            if(grid[i][j] == '.') q.push({i, j});
        }
    }
    while(!q.empty()) {
        int currI = q.front().first;
        int currJ = q.front().second;
        q.pop();
        for(int l = 0; l < 4; ++l) {
            const int i = currI-dirsI[l];
            const int j = currJ-dirsJ[l];
            if(bounds(i, j) && bounds(i+1, j+1)) {
                vector<pair<int, int>> spots;
                for(int k = 0; k < 4; ++k) {
                    const int toI = i+dirsI[k];
                    const int toJ = j+dirsJ[k];
                    if(grid[toI][toJ] == '*') {
                        spots.push_back({toI, toJ});
                    }
                }
                if(spots.size() == 1) {
                    grid[spots[0].first][spots[0].second] = '.';
                    q.push(spots[0]);
                }
            }
        }
    }
    for(int i = 0; i < n; ++i) {
        cout << grid[i] << '\n';
    }
    return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	//if (used[i][j]) return;
	if (i < n&&j < m) {
		if (count_star(i, j) == 1) {
			if (a[i][j]) q.push({ i, j }); else
			if (a[i + 1][j]) q.push({ i + 1, j }); else
			if (a[i][j + 1]) q.push({ i, j + 1 }); else
			if (a[i + 1][j + 1]) q.push({ i + 1, j + 1 });
		}
	}
}
void solve()
{
	cin >> n >> m;
	string s;

	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		if (i > 0 && j > 0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
		check(i, j);
		//used[i][j] = true;
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	if (count_star(i, j) == 1) {
		if (a[i][j]) q.push({ i, j });
		if (a[i+1][j]) q.push({ i+1, j });
		if (a[i][j+1]) q.push({ i, j+1 });
		if (a[i+1][j+1]) q.push({ i+1, j+1 });
	}
}
void solve()
{
	cin >> n >> m;
	string s;
	memset(a, 1, sizeof(a));
	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		//used[i][j] = true;
		q.pop();
		a[i][j] = 0;
		if (i > 0 && j > 0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	if (i < n&&j < m) {
		if (count_star(i, j) == 1) {
			int I = i, J = j;

			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
			I = i + 1;
			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
			J = j + 1;
			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
			I = i;
			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
		}
	}
}
void solve()
{
	cin >> n >> m;
	string s;

	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n + 1) a[i][m] = 1;
	REP(i, 0, m + 1) a[n][i] = 1;
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		check(i, j);
		if (i > 0) { check(i - 1, j); if (j > 0) check(i - 1, j - 1); }
		if (j > 0) check(i, j - 1);
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	if (count_star(i, j) == 1) {
		if (a[i][j]) q.push({ i, j });
		if (a[i+1][j]) q.push({ i+1, j });
		if (a[i][j+1]) q.push({ i, j+1 });
		if (a[i+1][j+1]) q.push({ i+1, j+1 });
	}
}
void solve()
{
	cin >> n >> m;
	string s;
	memset(a, 1, sizeof(a));
	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		//used[i][j] = true;
		q.pop();
		a[i][j] = 0;
		if (i > 0 && j > 0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
		check(i, j);
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	if (count_star(i, j) == 1) q.push({ i, j });
}
void solve()
{
	cin >> n >> m;
	string s;
	memset(a, 1, sizeof(a));
	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		if (i>0&&j>0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	if (used[i][j]) return;
	if (count_star(i, j) == 1) {
		if (a[i][j]) q.push({ i, j }); else
		if (a[i + 1][j]) q.push({ i + 1, j }); else
		if (a[i][j + 1]) q.push({ i, j + 1 }); else
		if (a[i + 1][j + 1]) q.push({ i + 1, j + 1 });
	}
}
void solve()
{
	cin >> n >> m;
	string s;
	memset(a, 1, sizeof(a));
	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		if (i > 0 && j > 0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
		check(i, j);
		used[i][j] = true;
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	//if (used[i][j]) return;
	if (i < n&&j < m) {
		if (count_star(i, j) == 1) {
			if (a[i][j] && !used[i][j]) q.push({ i, j }); else
			if (a[i + 1][j] && !used[i + 1][j]) q.push({ i + 1, j }); else
			if (a[i][j + 1] && !used[i][j + 1]) q.push({ i, j + 1 }); else
			if (a[i + 1][j + 1] && !used[i + 1][j + 1]) q.push({ i + 1, j + 1 });
		}
	}
}
void solve()
{
	cin >> n >> m;
	string s;
	memset(a, 1, sizeof(a));
	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		if (i > 0 && j > 0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
		check(i, j);
		//used[i][j] = true;
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	//if (used[i][j]) return;
	if (count_star(i, j) == 1) {
		if (a[i][j]) q.push({ i, j }); else
		if (a[i + 1][j]) q.push({ i + 1, j }); else
		if (a[i][j + 1]) q.push({ i, j + 1 }); else
		if (a[i + 1][j + 1]) q.push({ i + 1, j + 1 });
	}
}
void solve()
{
	cin >> n >> m;
	string s;
	memset(a, 1, sizeof(a));
	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		if (i > 0 && j > 0) check(i - 1, j - 1);
		if (i > 0) check(i - 1, j);
		if (j > 0) check(i, j - 1);
		check(i, j);
		//used[i][j] = true;
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//	system("pause");
	return 0;
}


/*
ID: temurxo1
PROG: spin
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;

#define dout if (debug) cout
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define Coder_404 true
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpi;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
typedef long double ld;
typedef long long ll;
const int inf = 1000000000;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000000ll;
const ld EPS = 1e-9;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
template <typename T>T gcd(T a, T b){ return b ? gcd(b, a%b) : a; }
template <typename T>T lcm(T a, T b){ return a*(b / gcd(a, b)); }
template <typename T>T sqr(T a) { return a*a; }
template <typename T>T cub(T a) { return a*a*a; }
bool pal(string &x) { int n = x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }

#define tests 	0
#define debug 	1
#define N  2111
int a[N][N];
int used[N][N];
int n, m;
queue<pii> q;

int count_star(int i, int j) {
	return (a[i][j] + a[i][j + 1] + a[i + 1][j] + a[i + 1][j + 1]);
}
void check(int i, int j) {
	if (i < n&&j < m) {
		if (count_star(i, j) == 1) {
			int I=i, J=j;

			if (a[I][J] && !used[I][J]) {
				used[I][J]= true;
				q.push(mp(I, J));
				return;
			}
			I = i + 1;
			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
			J = j + 1;
			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
			I = i;
			if (a[I][J] && !used[I][J]) {
				used[I][J] = true;
				q.push(mp(I, J));
				return;
			}
		}
	}
}
void solve()
{
	cin >> n >> m;
	string s;

	REP(i, 0, n) {
		cin >> s;
		REP(j, 0, m) {
			a[i][j] = (s[j] == '*');
		}
	}
	REP(i, 0, n + 1) a[i][m] = 1;
	REP(i, 0, m + 1) a[n][i] = 1;
	REP(i, 0, n) {
		REP(j, 0, m) {
			check(i, j);
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		a[i][j] = 0;
		check(i, j);
		if (i > 0) {check(i - 1, j); if (j > 0) check(i - 1, j);}
		if (j > 0) check(i, j - 1);
	}
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (a[i][j]) cout << '*'; else cout << '.';
		} cout << endl;
	}
}

int main()
{
	//freopen("spin.in", "r", stdin);
	//freopen("spin.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	if (tests) cin >> t;
	while (t--) solve();
	//	system("pause");
	return 0;
}


#include <iostream>

using namespace std;

const int NMAX = 3000;

char a[NMAX][NMAX];

void solve(int x, int y) {
  int i,j, no = 0;
  for(i = 0; i < 2; i++)
    for(j = 0;j < 2; j++)
      no += a[x + i][y + j] == '.';

  if(no == 3) {
    for(i = 0;i < 2; i++)
     for(j = 0;j < 2; j++)
      a[x + i][y + j] = '.';

      for(i = -1; i < 2; i++)
        for(j = -1; j < 2; j++)
          solve(x + i,y + j);
	}
}

int main()
{
  int n, m;
  cin >> n >> m;

  for(int i = 1; i <= n; i++)
    cin >> (a[i] + 1);

  for(int i = 1; i < n; i++)
    for(int j = 1; j < m; j++)
      solve(i,j);

  for(int i = 1; i <= n; i++)
    cout << (a[i] + 1) << '\n';
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
/// from HUNG MINE with love <3
int a[3001][3001], n, m;
void dfs (int x, int y) {
      if (x < 1 || y < 1 || x > n || y > m) return;
      int d = 0;
      for (int i = -1; i <= 0; ++ i) {
            for (int j = -1; j <= 0; ++ j) {
                  if (x + i < 1 || y + j < 1) return;
                  else if (a[x + i][y + j] == 0) {
                        ++ d;
                  }
            }
      }
      //cout << x << " " << y << " " << d << "\n";
      if (d != 3) return;
      for (int i = -1; i <= 0; ++ i) {
            for (int j = -1; j <= 0; ++ j) {
                  a[x + i][y + j] = 0;
            }
      }
      for (int i = -1; i <= 1; ++ i) {
            for (int j = -1; j <= 1; ++ j) {
                  dfs (x + i, y + j);
            }
      }
}
int main () {
      if (fopen ("test.inp", "r")) {
            freopen ("test.inp", "r", stdin);
      }
//      else {
//            freopen (".inp", "r", stdin);
//            freopen (".out", "w", stdout);
//      }

      ios_base :: sync_with_stdio (0);
      cin.tie (0);
      cout.tie (0);
      cin >> n >> m;
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  char c;
                  cin >> c;
                  a[i][j] = (c == '*');
            }
      }
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  dfs (i, j);
            }
      }
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  if (a[i][j] == 0) {
                        cout << ".";
                  }
                  else {
                        cout << "*";
                  }
            }
            cout << "\n";
      }
}


#include<bits/stdc++.h>
using namespace std;
/// from HUNG MINE with love <3
int a[2001][2001], n, m;
void dfs (int x, int y) {
      int d = 0;
      for (int i = -1; i <= 0; ++ i) {
            for (int j = -1; j <= 0; ++ j) {
                  if (x + i < 1 || y + j < 1) return;
                  else if (a[x + i][y + j] == 0) {
                        ++ d;
                  }
            }
      }
      //cout << x << " " << y << " " << d << "\n";
      if (d != 3) return;
      for (int i = -1; i <= 0; ++ i) {
            for (int j = -1; j <= 0; ++ j) {
                  a[x + i][y + j] = 0;
            }
      }
      for (int i = -1; i <= 1; ++ i) {
            for (int j = -1; j <= 1; ++ j) {
                  dfs (x + i, y + j);
            }
      }
}
int main () {
      if (fopen ("test.inp", "r")) {
            freopen ("test.inp", "r", stdin);
      }
//      else {
//            freopen (".inp", "r", stdin);
//            freopen (".out", "w", stdout);
//      }

      ios_base :: sync_with_stdio (0);
      cin.tie (0);
      cout.tie (0);
      cin >> n >> m;
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  char c;
                  cin >> c;
                  a[i][j] = (c == '*');
            }
      }
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  dfs (i, j);
            }
      }
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  if (a[i][j] == 0) {
                        cout << ".";
                  }
                  else {
                        cout << "*";
                  }
            }
            cout << "\n";
      }
}


#include<bits/stdc++.h>
using namespace std;
/// from HUNG MINE with love <3
int a[3001][3001], n, m;
void dfs (int x, int y) {
      int d = 0;
      for (int i = -1; i <= 0; ++ i) {
            for (int j = -1; j <= 0; ++ j) {
                  if (x + i < 1 || y + j < 1) return;
                  else if (a[x + i][y + j] == 0) {
                        ++ d;
                  }
            }
      }
      //cout << x << " " << y << " " << d << "\n";
      if (d != 3) return;
      for (int i = -1; i <= 0; ++ i) {
            for (int j = -1; j <= 0; ++ j) {
                  a[x + i][y + j] = 0;
            }
      }
      for (int i = -1; i <= 1; ++ i) {
            for (int j = -1; j <= 1; ++ j) {
                  dfs (x + i, y + j);
            }
      }
}
int main () {
      if (fopen ("test.inp", "r")) {
            freopen ("test.inp", "r", stdin);
      }
//      else {
//            freopen (".inp", "r", stdin);
//            freopen (".out", "w", stdout);
//      }

      ios_base :: sync_with_stdio (0);
      cin.tie (0);
      cout.tie (0);
      cin >> n >> m;
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  char c;
                  cin >> c;
                  a[i][j] = (c == '*');
            }
      }
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  dfs (i, j);
            }
      }
      for (int i = 1; i <= n; ++ i) {
            for (int j = 1; j <= m; ++ j) {
                  if (a[i][j] == 0) {
                        cout << ".";
                  }
                  else {
                        cout << "*";
                  }
            }
            cout << "\n";
      }
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = 3.1415926535897932384626433832795;
const int N = 2e3 + 5;

char ch[N][N];
queue <pair<int, int> > q;
int n, m;

bool ok(int x, int y){

	if(ch[x][y] != '*')
		return false;
	if(x < 1 || x > n || y < 1|| y > m)
		return false;
	if(ch[x + 1][y] == '.' and ch[x + 1][y + 1] == '.' and ch[x][y + 1] == '.')
		return true;
	if(ch[x - 1][y] == '.' and ch[x - 1][y + 1] == '.' and ch[x][y + 1] == '.')
		return true;
	if(ch[x + 1][y] == '.' and ch[x + 1][y - 1] == '.' and ch[x][y - 1] == '.')
		return true;
	if(ch[x - 1][y] == '.' and ch[x - 1][y - 1] == '.' and ch[x][y - 1] == '.')
		return true;
	return false;
}

int main(){_
	cin >> n >> m;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> ch[i][j];

	for(int i = 0; i <= n + 1; i++)
		ch[i][0] = ch[i][m + 1] = '*';
	for(int i = 0; i <= m + 1; i++)
		ch[0][i] = ch[n + 1][i] = '*';

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(ok(i, j))
				q.push({i, j});

	while(!q.empty()){
		int x = q.front().fi, y = q.front().se;
		q.pop();
		ch[x][y] = '.';
		for(int i = -1; i <= 1; i++)
			for(int j = -1; j <= 1; j++){
				if(i == 0 and j == 0)
					continue;
				if(ok(x + i, y + j))
					q.push({x + i, y + j});
			}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++)
			cout << ch[i][j];
		cout << '\n';
	}
	return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = 3.1415926535897932384626433832795;
const int N = 2e3 + 5;

char ch[N][N];
int vis[N][N];
queue <pair<int, int> > q;
int n, m;

bool ok(int x, int y){

	if(ch[x][y] != '*')
		return false;
	if(x < 1 || x > n || y < 1|| y > m)
		return false;
	if(ch[x + 1][y] == '.' and ch[x + 1][y + 1] == '.' and ch[x][y + 1] == '.')
		return true;
	if(ch[x - 1][y] == '.' and ch[x - 1][y + 1] == '.' and ch[x][y + 1] == '.')
		return true;
	if(ch[x + 1][y] == '.' and ch[x + 1][y - 1] == '.' and ch[x][y - 1] == '.')
		return true;
	if(ch[x - 1][y] == '.' and ch[x - 1][y - 1] == '.' and ch[x][y - 1] == '.')
		return true;
	return false;
}

int main(){_
	cin >> n >> m;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> ch[i][j];

	for(int i = 0; i <= n + 1; i++)
		ch[i][0] = ch[i][m + 1] = '*';
	for(int i = 0; i <= m + 1; i++)
		ch[0][i] = ch[n + 1][i] = '*';

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(ok(i, j)){
				q.push({i, j});
				vis[i][j] = 1;
			}

	while(!q.empty()){
		int x = q.front().fi, y = q.front().se;
		q.pop();
		ch[x][y] = '.';
		for(int i = -1; i <= 1; i++)
			for(int j = -1; j <= 1; j++){
				if(i == 0 and j == 0)
					continue;
				if(!vis[x + i][y +j] and ok(x + i, y + j)){
					q.push({x + i, y + j});
					vis[x + i][y + j] = 1;
				}
			}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++)
			cout << ch[i][j];
		cout << '\n';
	}
	return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = 3.1415926535897932384626433832795;
const int N = 2e3 + 5;

char ch[N][N];
queue <pair<int, int> > q;
int n, m;

bool ok(int x, int y){

	if(ch[x][y] != '*')
		return false;
	if(x < 1 || x > n || y < 1|| y > m)
		return false;
	if(ch[x + 1][y] == '.' and ch[x + 1][y + 1] == '.' and ch[x][y + 1] == '.')
		return true;
	if(ch[x - 1][y] == '.' and ch[x - 1][y + 1] == '.' and ch[x][y + 1] == '.')
		return true;
	if(ch[x + 1][y] == '.' and ch[x + 1][y - 1] == '.' and ch[x][y - 1] == '.')
		return true;
	if(ch[x - 1][y] == '.' and ch[x - 1][y - 1] == '.' and ch[x][y - 1] == '.')
		return true;
	return false;
}

int main(){_
	cin >> n >> m;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> ch[i][j];

	for(int i = 0; i <= n + 1; i++)
		ch[i][0] = ch[i][m + 1] = '*';
	for(int i = 0; i <= m + 1; i++)
		ch[0][i] = ch[n + 1][i] = '*';

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(ok(i, j)){
				q.push({i, j});
				ch[i][j] = '.';
			}

	while(!q.empty()){
		int x = q.front().fi, y = q.front().se;
		q.pop();
		for(int i = -1; i <= 1; i++)
			for(int j = -1; j <= 1; j++){
				if(i == 0 and j == 0)
					continue;
				if(ok(x + i, y + j)){
					q.push({x + i, y + j});
					ch[x + i][y + j] = '.';
				}
			}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++)
			cout << ch[i][j];
		cout << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) <= (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2005;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  return (i>0 && i<n && j>0 && j<m);
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  For(k,0,1)
    For(h,0,1)
      if(mat[i+k][j+h]=='*') c++,p=i+k,q=j+h;
  if(c==1)
  {
    mat[p][q]='.';
    For(k,-1,0)
      For(u,-1,0)
        if(valid(p+k,q+u))
        bfs(p+k,q+u);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
const ll M = 2005;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
ll n,m,d,r,ans;
char mat[M][M];
ll vis[M][M],dp[M][M];
ll l=INF;
ll u=INF;

bool valid(ll i,ll j)
{
  if(i>=1 && i<=n && j>=1 && j<=m && mat[i][j]=='.' && vis[i][j]==0)
    return true;
  return false;
}

void dfs(ll i,ll j)
{
  vis[i][j]=1;
  l=min(l,j),u=min(u,i),d=max(d,i),r=max(r,j);
  if(valid(i+1,j))
    dfs(i+1,j);
  if(valid(i-1,j))
    dfs(i-1,j);
  if(valid(i,j+1))
    dfs(i,j+1);
  if(valid(i,j-1))
    dfs(i,j-1);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n)
  {
    rep(j,m)
    {
      if(mat[i][j]=='*') continue;
      if(vis[i][j]) continue;

      dfs(i,j);
      //cout << i << " "<< j << " "<<  u << " "<< l << " " << d << " " << r << endl;
      for(ll k=u;k<=d;k++)
      {
        for(ll p=l;p<=r;p++)
        {
          if(mat[k][p]=='*')
            mat[k][p]='.';
        }
      }
      u=INF,l=INF;
      d=r=0;
    }
  }
  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
//#define For(i,a,b) for(ll (i)=(a);(i) <= (b); ++(i))
//#define rof(i,a,b) for(ll (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2025;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  if((i>0) && (i<n) && (j>0) && (j<m))
    return true;
  return false;
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  for(ll k=0;k<=1;k++)
  {
    for(ll h=0;h<=1;h++)
    {
      if(((i+k)<=n) && ((j+h)<=m) && (mat[i+k][j+h]=='*'))
         c++,p=i+k,q=j+h;
    }
  }

  if(c==1)
  {
    mat[p][q]='.';
    for(ll t=-1;t<=1;t++)
    {
      for(ll u=-1;u<=1;u++)
      {
        if(valid(i+t,j+u))
          bfs(i+t,j+u);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
//#define For(i,a,b) for(ll (i)=(a);(i) <= (b); ++(i))
//#define rof(i,a,b) for(ll (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2025;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  if((i>0) && (i<n) && (j>0) && (j<m))
    return true;
  return false;
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  for(ll k=0;k<=1;k++)
  {
    for(ll h=0;h<=1;h++)
    {
      if(mat[i+k][j+h]=='.')
         c++;
    }
  }

  if(c==3)
  {
    for(ll k=0;k<=1;k++)
    {
      for(ll h=0;h<=1;h++)
      {
        mat[i+k][j+h]='.';
      }
    }

    for(ll t=-1;t<=1;t++)
    {
      for(ll u=-1;u<=1;u++)
      {
          bfs(i+t,j+u);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) <= (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2005;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  return (i>0 && i<n && j>0 && j<m);
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  For(k,0,1)
    For(h,0,1)
      if(i+k<=n && j+h<=m && mat[i+k][j+h]=='*') c++,p=i+k,q=j+h;
  if(c==1)
  {
    mat[p][q]='.';
    For(k,-1,0)
      For(u,-1,0)
        if(valid(p+k,q+u))
        bfs(p+k,q+u);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(ll (i)=(a);(i) <= (b); ++(i))
#define rof(i,a,b) for(ll (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2025;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  return (i>0 && i<n && j>0 && j<m);
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  for(ll k=0;k<=1;k++)
  {
    for(ll h=0;h<=1;h++)
    {
      if(((i+k)<=n) && ((j+h)<=m) && (mat[i+k][j+h]=='*'))
         c++,p=i+k,q=j+h;
    }
  }

  if(c==1)
  {
    mat[p][q]='.';
    for(ll t=-1;t<=1;t++)
    {
      for(ll u=-1;u<=1;u++)
      {
        if(valid(i+t,j+u))
          bfs(i+t,j+u);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) <= (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2025;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  return (i>0 && i<n && j>0 && j<m);
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  For(k,0,1)
    For(h,0,1)
      if(((i+k)<=n) && ((j+h)<=m) && (mat[i+k][j+h]=='*')) c++,p=i+k,q=j+h;
  if(c==1)
  {
    mat[p][q]='.';
    For(k,-1,1)
      For(u,-1,1)
        if(valid(p+k,q+u))
        bfs(p+k,q+u);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
//#define For(i,a,b) for(ll (i)=(a);(i) <= (b); ++(i))
//#define rof(i,a,b) for(ll (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2025;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  return (i>0 && i<n && j>0 && j<m);
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  for(ll k=0;k<=1;k++)
  {
    for(ll h=0;h<=1;h++)
    {
      if(((i+k)<=n) && ((j+h)<=m) && (mat[i+k][j+h]=='*'))
         c++,p=i+k,q=j+h;
    }
  }

  if(c==1)
  {
    mat[p][q]='.';
    for(ll t=-1;t<=1;t++)
    {
      for(ll u=-1;u<=1;u++)
      {
        if(valid(i+t,j+u))
          bfs(i+t,j+u);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(ll (i)=(a);(i) <= (b); ++(i))
#define rof(i,a,b) for(ll (i)=(a);(i) >= (b); --(i))
#define rep(i, n) for(ll i = 1; i <= n; i++)
#define pb push_back
#define sz(a) ll((a).size())
const ll M = 2025;
const ll INF=1e15+5;
const ll MOD = 1e9+7;
const ll N=2e5;
const double PI= 3.14159265358979323846;
#define mp make_pair
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi,pi> piii;
typedef vector<ll> vi;
typedef vector<pi> vii;
typedef vector< vi > matrix;
char mat[M][M];
ll n,m;

bool valid(ll i,ll j)
{
  return (i>0 && i<n && j>0 && j<m);
}

void bfs(ll i,ll j)
{
  ll c=0;
  ll p,q;
  For(k,0,1)
    For(h,0,1)
      if(((i+k)<=n) && ((j+h)<=m) && (mat[i+k][j+h]=='*')) c++,p=i+k,q=j+h;
  if(c==1)
  {
    mat[p][q]='.';
    For(t,-1,1)
      For(u,-1,1)
        if(valid(i+t,j+u))
        bfs(i+t,j+u);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;
  rep(i,n)
  {
    string s;
    cin >> s ;
    rep(j,m)
      mat[i][j]=s[j-1];
  }

  rep(i,n-1)
  {
    rep(j,m-1)
      bfs(i,j);
  }

  rep(i,n)
  {
    rep(j,m)
      cout << mat[i][j];
    cout << "\n";
  }
}


#include <bits/stdc++.h>

#define F first
#define S second

#define ll long long
#define ull unsigned long long
#define ld long double

#define pb push_back
#define ppb pop_back
#define mp make_pair

#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define bit(x) __builtin_popcountll(x)
#define sqr(x) ((x) * 1LL * (x))

#define nl '\n'
#define ioi exit(0);

#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

using namespace std;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const int N = 1e5 + 7, MxN = 1e6 + 7, mod = 1e9 + 7, inf = 2e9 + 7;
const long long linf = 1e18 + 7;
const double eps = 1e-9;
const int ii[] = {-1, 0, 1, 0, 1, -1, -1, 1}, jj[] = {0, 1, 0, -1, 1, -1, 1, -1};

    int n, m, cnt, cur;
    pii pos;
    pii q[MxN * 10];
    bool was[2001][2001];
    char a[2001][2001];
    inline bool Check(int x, int y){
        return x >= 0 && x < n && y >= 0 && y < m;
    }
    inline bool Get(int i, int j){
        if (i == n - 1 || j == m - 1) return 0;
        if ((a[i][j] == '*') + (a[i + 1][j] == '*') + (a[i][j + 1] == '*') + (a[i + 1][j + 1] == '*') == 1){
            return 1;
        }
        return 0;
    }
int main(){
    scanf ("%d%d", &n, &m);
    for (int i = 0; i < n; i++){
        scanf ("\n");
        scanf ("%s", &a[i]);
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (Get(i, j)) q[++cur] = {i, j};

    while (cur){
        int x = q[cur].F, y = q[cur].S;
        cur--;
        if (Get(x, y)){
            a[x][y] = a[x][y + 1] = a[x + 1][y] = a[x + 1][y + 1] = '.';
            for (int i = 0; i < 8; i++)
                if (Check(x + ii[i], y + jj[i]) && Get(x + ii[i], y + jj[i]))
                    q[++cur] = {x + ii[i], y + jj[i]};
        }
    }

    for (int i = 0; i < n; i++, printf("\n"))
        printf ("%s", a[i]);
    ioi
}


#include <bits/stdc++.h>

#define F first
#define S second

#define ll long long
#define ull unsigned long long
#define ld long double

#define pb push_back
#define ppb pop_back
#define mp make_pair

#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define bit(x) __builtin_popcountll(x)
#define sqr(x) ((x) * 1LL * (x))

#define nl '\n'
#define ioi exit(0);

#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

using namespace std;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;

const int N = 1e5 + 7, MxN = 1e6 + 7, mod = 1e9 + 7, inf = 2e9 + 7;
const long long linf = 1e18 + 7;
const double eps = 1e-9;
const int ii[] = {-1, 0, 1, 0, 1, -1, -1, 1}, jj[] = {0, 1, 0, -1, 1, -1, 1, -1};

    int n, m, cnt;
    pii pos;
    queue <pii> q;
    bool was[2001][2001];
    char a[2001][2001];
    inline bool Check(int x, int y){
        return x >= 1 && x <= n && y >= 1 && y <= m;
    }
    inline bool Get(int i, int j){
        if (i == n || j == m) return 0;
        if ((a[i][j] == '*') + (a[i + 1][j] == '*') + (a[i][j + 1] == '*') + (a[i + 1][j + 1] == '*') == 1){
            return 1;
        }
        return 0;
    }
int main(){
    scanf ("%d%d", &n, &m);
    for (int i = 1; i <= n; i++){
        scanf ("\n");
        for (int j = 1; j <= m; j++)
            scanf ("%c", &a[i][j]);
    }
    for (int i = 1; i < n; i++)
        for (int j = 1; j < m; j++)
            if (Get(i, j)) q.push({i, j});

    while (sz(q)){
        int x = q.front().F, y = q.front().S;
        q.pop();
        if (Get(x, y)){
            a[x][y] = a[x][y + 1] = a[x + 1][y] = a[x + 1][y + 1] = '.';
            for (int i = 0; i < 8; i++)
                if (Check(x + ii[i], y + jj[i]) && Get(x + ii[i], y + jj[i]))
                    q.push({x + ii[i], y + jj[i]});
        }
    }

    for (int i = 1; i <= n; i++, printf("\n"))
        for (int j = 1; j <= m; j++)
            printf ("%c", a[i][j]);
    ioi
}


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

int n, m;
vector<vector<char> > arr;
queue<pair<int, int> > q;

void check(int x, int y)
{
	int u = 0;
	for(int i = x; i <= x + 1; ++i)
	{
		for(int j = y; j <= y + 1; ++j)
		{
			if(arr[i][j] == '*')
			{
				++u;
			}
		}
	}
	if(u == 1)
	{
		if(arr[x][y] == '*')
		{
			arr[x][y] = '.';
			q.push(make_pair(x, y));
		} else if(arr[x + 1][y] == '*')
		{
			arr[x + 1][y] = '.';
			q.push(make_pair(x + 1, y));
		} else if(arr[x][y + 1] == '*')
		{
			arr[x][y + 1] = '.';
			q.push(make_pair(x, y + 1));
		} else
		{
			arr[x + 1][y + 1] = '.';
			q.push(make_pair(x + 1, y + 1));
		}
	}
}

void solve()
{
	for(int i = 0; i + 1 < n; ++i)
	{
		for(int j = 0; j + 1 < m; ++j)
		{
			int u = 0;
			for(int I = 0; I < 2; ++I)
			{
				for(int J = 0; J < 2; ++J)
				{
					if(arr[i + I][j + J] == '*')
					{
						++u;
					}
				}
			}
			if(u == 1)
			{
				for(int I = i; I <= i + 1; ++I)
				{
					for(int J = j; J <= j + 1; ++J)
					{
						if(arr[I][J] == '*')
						{
							arr[I][J] = '.';
							q.push(make_pair(I, J));
						}
					}
				}
			}
		}
	}
	while(!q.empty())
	{
		int x = q.front().first,
			y = q.front().second;
		q.pop();
		if(x > 0 && y > 0)
		{
			check(x - 1, y - 1);
		}
		if(x > 0 && y + 1 < m)
		{
			check(x - 1, y);
		}
		if(x + 1 < n && y > 0)
		{
			check(x, y - 1);
		}
		if(x + 1 < n && y + 1 < m)
		{
			check(x, y);
		}
	}
}

int main (int argc, char *argv[])
{
	//FILE *in = freopen("input.txt", "r", stdin);

	scanf("%d%d", &n, &m);
	arr.resize(n);
	for(int i = 0; i < n; ++i)
	{
		arr[i].resize(m);
		char s[m + 1];
		scanf("%s", s);
		for(int j = 0; j < m; ++j)
		{
			arr[i][j] = s[j];
		}
	}
	solve();
	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < m; ++j)
		{
			printf("%c", arr[i][j]);
		}
		printf("\n");
	}

	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

using namespace std;

const int N=2009;

char s1[N][N];
int n,m;
bool vis[N][N];
queue< pair<int,int> > q;
int dr[]={-1,-1,-1,0,0,1,1,1},dc[]={-1,0,1,-1,1,-1,0,1};

bool check(int ro,int co){
	int i,j,t1,t2,t3,t4;
	if(s1[ro][co]=='.'){
		return false;
	}
	// top left corner
	if(ro<n-1 && co<m-1){
		if(s1[ro][co+1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co+1]=='.'){
			return true;
		}
	}
	// top right corner
	if(ro<n-1 && co>0){
		if(s1[ro][co-1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co-1]=='.'){
			return true;
		}
	}
	// bottom left corner
	if(ro>0 && co<m-1){
		if(s1[ro-1][co]=='.' && s1[ro-1][co+1]=='.' && s1[ro][co+1]=='.'){
			return true;
		}
	}
	// bottom right corner
	if(ro>0 && co>0){
		if(s1[ro-1][co-1]=='.' && s1[ro-1][co]=='.' && s1[ro][co-1]=='.'){
			return true;
		}
	}
	return false;
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i,j)){
				q.push(make_pair(i,j));
				vis[i][j]=1;
			}
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		for(i=0;i<8;i++){
			t1=it.first+dr[i];
			t2=it.second+dc[i];
			if(t1>=0 && t1<n && t2>=0 && t2<m){
				if(!vis[t1][t2] && check(t1,t2)){
					q.push(make_pair(t1,t2));
					vis[t1][t2]=1;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

using namespace std;

const int N=2009;

char s1[N][N];
int vis[N][N],n,m;
queue< pair<int,int> > q;
int dr[]={-1,-1,-1,0,0,1,1,1},dc[]={-1,0,1,-1,1,-1,0,1};

bool check(int ro,int co){
	int i,j,t1,t2,t3,t4;
	if(s1[ro][co]=='.'){
		return false;
	}
	// top left corner
	if(ro<n-1 && co<m-1){
		if(s1[ro][co+1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co+1]=='.'){
			return true;
		}
	}
	// top right corner
	if(ro<n-1 && co>0){
		if(s1[ro][co-1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co-1]=='.'){
			return true;
		}
	}
	// bottom left corner
	if(ro>0 && co<m-1){
		if(s1[ro-1][co]=='.' && s1[ro-1][co+1]=='.' && s1[ro][co+1]=='.'){
			return true;
		}
	}
	// bottom right corner
	if(ro>0 && co>0){
		if(s1[ro-1][co-1]=='.' && s1[ro-1][co]=='.' && s1[ro][co-1]=='.'){
			return true;
		}
	}
	return false;
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i,j)){
				q.push(make_pair(i,j));
				vis[i][j]=1;
			}
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		for(i=0;i<8;i++){
			t1=it.first+dr[i];
			t2=it.second+dc[i];
			if(t1>=0 && t1<n && t2>=0 && t2<m){
				if(!vis[t1][t2] && check(t1,t2)){
					q.push(make_pair(t1,t2));
					vis[t1][t2]=1;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

using namespace std;

const int N=2009;

char s1[N][N];
int n,m;
bool vis[N][N];
queue< pair<int,int> > q;

void checker(int ro,int co,int dr,int dc){
	int i,j,t1,t2,t3,t4,cnt=0;
	for(i=0;i<2;i++){
		for(j=0;j<2;j++){
			if(s1[ro+i*dr][co+j*dc]=='*'){
				cnt++;
				t1=ro+i*dr;
				t2=co+j*dc;
			}
		}
	}
	if(cnt==1 && !vis[t1][t2]){
		q.push(make_pair(t1,t2));
	}
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=0;j<m-1;j++){
			checker(i,j,1,1);
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		vis[it.first][it.second]=1;
		if(it.first<n-1 && it.second<m-1){
			checker(it.first,it.second,1,1);
		}
		if(it.first>0 && it.second<m-1){
			checker(it.first,it.second,-1,1);
		}
		if(it.first>0 && it.second>0){
			checker(it.first,it.second,-1,-1);
		}
		if(it.first<n-1 && it.second>0){
			checker(it.first,it.second,1,-1);
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

#define N 2009

using namespace std;

char s1[N][N];
int vis[N][N],n,m;
queue< pair<int,int> > q;

void checker(int ro,int co,int dr,int dc){
	int i,j,t1,t2,t3,t4,cnt=0;
	for(i=0;i<2;i++){
		for(j=0;j<2;j++){
			if(s1[ro+i*dr][co+j*dc]=='*'){
				cnt++;
				t1=ro+i*dr;
				t2=co+j*dc;
			}
		}
	}
	if(cnt==1 && !vis[t1][t2]){
		q.push(make_pair(t1,t2));
	}
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=0;j<m-1;j++){
			checker(i,j,1,1);
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		vis[it.first][it.second]=1;
		if(it.first<n-1 && it.second<m-1){
			checker(it.first,it.second,1,1);
		}
		if(it.first>0 && it.second<m-1){
			checker(it.first,it.second,-1,1);
		}
		if(it.first>0 && it.second>0){
			checker(it.first,it.second,-1,-1);
		}
		if(it.first<n-1 && it.second>0){
			checker(it.first,it.second,1,-1);
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

#define N 2009

using namespace std;

char s1[N][N];
int vis[N][N],n,m;
queue< pair<int,int> > q;
int dr[]={-1,-1,-1,0,0,1,1,1},dc[]={-1,0,1,-1,1,-1,0,1};

bool check(int ro,int co){
	int i,j,t1,t2,t3,t4;
	if(s1[ro][co]=='.'){
		return false;
	}
	// top left corner
	if(ro<n-1 && co<m-1){
		if(s1[ro][co+1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co+1]=='.'){
			return true;
		}
	}
	// top right corner
	if(ro<n-1 && co>0){
		if(s1[ro][co-1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co-1]=='.'){
			return true;
		}
	}
	// bottom left corner
	if(ro>0 && co<m-1){
		if(s1[ro-1][co]=='.' && s1[ro-1][co+1]=='.' && s1[ro][co+1]=='.'){
			return true;
		}
	}
	// bottom right corner
	if(ro>0 && co>0){
		if(s1[ro-1][co-1]=='.' && s1[ro-1][co]=='.' && s1[ro][co-1]=='.'){
			return true;
		}
	}
	return false;
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i,j)){
				q.push(make_pair(i,j));
			}
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		vis[it.first][it.second]=1;
		for(i=0;i<8;i++){
			t1=it.first+dr[i];
			t2=it.second+dc[i];
			if(t1>=0 && t1<n && t2>=0 && t2<m){
				if(!vis[t1][t2] && check(t1,t2)){
					q.push(make_pair(t1,t2));
				}
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

#define N 2009

using namespace std;

char s1[N][N];
int vis[N][N],n,m;
queue< pair<int,int> > q;
int dr[]={-1,-1,-1,0,0,1,1,1},dc[]={-1,0,1,-1,1,-1,0,1};

bool check(int ro,int co){
	int i,j,t1,t2,t3,t4;
	if(s1[ro][co]=='.'){
		return false;
	}
	// top left corner
	if(ro<n-1 && co<m-1){
		if(s1[ro][co+1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co+1]=='.'){
			return true;
		}
	}
	// top right corner
	if(ro<n-1 && co>0){
		if(s1[ro][co-1]=='.' && s1[ro+1][co]=='.' && s1[ro+1][co-1]=='.'){
			return true;
		}
	}
	// bottom left corner
	if(ro>0 && co<m-1){
		if(s1[ro-1][co]=='.' && s1[ro-1][co+1]=='.' && s1[ro][co+1]=='.'){
			return true;
		}
	}
	// bottom right corner
	if(ro>0 && co>0){
		if(s1[ro-1][co-1]=='.' && s1[ro-1][co]=='.' && s1[ro][co-1]=='.'){
			return true;
		}
	}
	return false;
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i,j)){
				q.push(make_pair(i,j));
				vis[i][j]=1;
			}
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		for(i=0;i<8;i++){
			t1=it.first+dr[i];
			t2=it.second+dc[i];
			if(t1>=0 && t1<n && t2>=0 && t2<m){
				if(!vis[t1][t2] && check(t1,t2)){
					q.push(make_pair(t1,t2));
					vis[t1][t2]=1;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

#define N 2009

using namespace std;

char s1[N][N];
int n,m;
int vis[N][N];
queue< pair<int,int> > q;

void checker(int ro,int co,int dr,int dc){
	int i,j,t1,t2,t3,t4,cnt=0;
	for(i=0;i<2;i++){
		for(j=0;j<2;j++){
			if(s1[ro+i*dr][co+j*dc]=='*'){
				cnt++;
				t1=ro+i*dr;
				t2=co+j*dc;
			}
		}
	}
	if(cnt==1 && !vis[t1][t2]){
		vis[t1][t2]=1;
		q.push(make_pair(t1,t2));
	}
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=0;j<m-1;j++){
			checker(i,j,1,1);
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		if(it.first<n-1 && it.second<m-1){
			checker(it.first,it.second,1,1);
		}
		if(it.first>0 && it.second<m-1){
			checker(it.first,it.second,-1,1);
		}
		if(it.first>0 && it.second>0){
			checker(it.first,it.second,-1,-1);
		}
		if(it.first<n-1 && it.second>0){
			checker(it.first,it.second,1,-1);
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <cassert>
#include <queue>
#include <string>
#include <stack>
#include <bitset>
#include <cmath>

using namespace std;

const int N=2009;

char s1[N][N];
int n,m;
bool vis[N][N];
queue< pair<int,int> > q;

void checker(int ro,int co,int dr,int dc){
	int i,j,t1,t2,t3,t4,cnt=0;
	for(i=0;i<2;i++){
		for(j=0;j<2;j++){
			if(s1[ro+i*dr][co+j*dc]=='*'){
				cnt++;
				t1=ro+i*dr;
				t2=co+j*dc;
			}
		}
	}
	if(cnt==1 && !vis[t1][t2]){
		vis[t1][t2]=1;
		q.push(make_pair(t1,t2));
	}
}

int main(){
	int i,j,t1,t2,t3,t4;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s1[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=0;j<m-1;j++){
			checker(i,j,1,1);
		}
	}
	while(!q.empty()){
		auto it=q.front();
		q.pop();
		s1[it.first][it.second]='.';
		//vis[it.first][it.second]=1;
		if(it.first<n-1 && it.second<m-1){
			checker(it.first,it.second,1,1);
		}
		if(it.first>0 && it.second<m-1){
			checker(it.first,it.second,-1,1);
		}
		if(it.first>0 && it.second>0){
			checker(it.first,it.second,-1,-1);
		}
		if(it.first<n-1 && it.second>0){
			checker(it.first,it.second,1,-1);
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",s1[i]);
	}
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define se second
#define pb push_back
#define nn 2010
#define pii pair<int,int>
#define mt make_tuple
#define ll long long int
#define pdd pair<long double,long double>
#define db double
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define inf 10000000000010ll
#define logn 20
#define mod 1000000007
#define mt make_tuple
#define nullp mp(-1,-1)

using namespace std;

short int s[nn][nn];
bool v[nn][nn];

pii check(int i,int j)
{
	pii ret(-1,-1);
	int a0=s[i][j]+s[i-1][j]+s[i-1][j-1]+s[i][j-1];
	int a1=s[i][j]+s[i-1][j]+s[i-1][j+1]+s[i][j+1];
	int a2=s[i][j]+s[i+1][j]+s[i+1][j+1]+s[i][j+1];
	int a3=s[i][j]+s[i+1][j]+s[i+1][j-1]+s[i][j-1];
	if(a0==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i-1][j])
			return mp(i-1,j);
		if(s[i-1][j-1]==1)
			return mp(i-1,j-1);
		return mp(i,j-1);
	}
	if(a1==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i-1][j])
			return mp(i-1,j);
		if(s[i-1][j+1]==1)
			return mp(i-1,j+1);
		return mp(i,j+1);
	}
	if(a2==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i+1][j])
			return mp(i+1,j);
		if(s[i+1][j+1]==1)
			return mp(i+1,j+1);
		return mp(i,j+1);
	}
	if(a3==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i+1][j])
			return mp(i+1,j);
		if(s[i+1][j-1]==1)
			return mp(i+1,j-1);
		return mp(i,j-1);
	}
	return ret;
}

void solve(int i,int j)
{
	if(!s[i][j])
		return;
	queue<pii>q;
	pii a=check(i,j);
	if(a==nullp)
		return;
	q.push(a);
	v[a.ff][a.se]=1;
	while(!q.empty())
	{
		pii t=q.front();
		a=check(t.ff,t.se);
		q.pop();
		while(a!=nullp)
		{
			s[a.ff][a.se]=0;
			if(!v[a.ff][a.se])
				q.push(a);
			v[a.ff][a.se]=1;
			a=check(t.ff,t.se);
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int n,m;
    cin>>n>>m;
    char ch;
    memset(s,1,sizeof s);
    list<pii>li;
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		cin>>ch,s[i][j]=(ch=='*')?1:0;
    		if(s[i][j])
    			li.pb(mp(i,j));
    	}
    }
    for(list<pii>::iterator u=li.begin();u!=li.end();u++)
    {
    	int i=u->ff,j=u->se;
    	if(s[i][j])
    		solve(i,j);
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    		cout<<((s[i][j])?'*':'.');
    	cout<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define se second
#define pb push_back
#define nn 2010
#define pii pair<int,int>
#define mt make_tuple
#define ll long long int
#define pdd pair<long double,long double>
#define db double
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define inf 10000000000010ll
#define logn 20
#define mod 1000000007
#define mt make_tuple
#define nullp mp(-1,-1)

using namespace std;

short int s[nn][nn];
bool v[nn][nn];

pii check(int i,int j)
{
	pii ret(-1,-1);
	int a0=s[i][j]+s[i-1][j]+s[i-1][j-1]+s[i][j-1];
	int a1=s[i][j]+s[i-1][j]+s[i-1][j+1]+s[i][j+1];
	int a2=s[i][j]+s[i+1][j]+s[i+1][j+1]+s[i][j+1];
	int a3=s[i][j]+s[i+1][j]+s[i+1][j+1]+s[i][j+1];
	if(a0==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i-1][j])
			return mp(i-1,j);
		if(s[i-1][j-1]==1)
			return mp(i-1,j-1);
		return mp(i,j-1);
	}
	if(a1==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i-1][j])
			return mp(i-1,j);
		if(s[i-1][j+1]==1)
			return mp(i-1,j+1);
		return mp(i,j+1);
	}
	if(a2==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i+1][j])
			return mp(i+1,j);
		if(s[i+1][j+1]==1)
			return mp(i+1,j+1);
		return mp(i,j+1);
	}
	if(a3==1)
	{
		if(s[i][j]==1)
			return mp(i,j);
		if(s[i+1][j])
			return mp(i+1,j);
		if(s[i+1][j-1]==1)
			return mp(i+1,j-1);
		return mp(i,j-1);
	}
	return ret;
}

void solve(int i,int j)
{
	if(!s[i][j])
		return;
	queue<pii>q;
	pii a=check(i,j);
	if(a==nullp)
		return;
	q.push(a);
	v[a.ff][a.se]=1;
	while(!q.empty())
	{
		pii t=q.front();
		a=check(t.ff,t.se);
		q.pop();
		while(a!=nullp)
		{
			s[a.ff][a.se]=0;
			if(!v[a.ff][a.se])
				q.push(a);
			v[a.ff][a.se]=1;
			a=check(t.ff,t.se);
		}
	}
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int n,m;
    cin>>n>>m;
    char ch;
    memset(s,1,sizeof s);
    list<pii>li;
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		cin>>ch,s[i][j]=(ch=='*')?1:0;
    		if(s[i][j])
    			li.pb(mp(i,j));
    	}
    }
    for(list<pii>::iterator u=li.begin();u!=li.end();u++)
    {
    	int i=u->ff,j=u->se;

    	solve(i,j);
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    		cout<<((s[i][j])?'*':'.');
    	cout<<'\n';
    }
    return 0;
}