public class Mavenproject5 {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        int m = in.nextInt();
        String[][] matrica = new String[n][m];
        for (int i = 0; i < matrica.length; i++) {
            for (int j = 0; j < matrica[0].length; j++) {
                matrica[i][j] = in.nextLine();
            }
        }
        
        for (int i = 0; i < matrica.length; i++) {
            for (int j = 0; j < matrica[0].length; j++) {
                if (matrica[i][j] == "X") {
                    matrica[i - 1][j] = "X";
                    matrica[i + 1][j] = "X";
                    matrica[i][j - 1] = "X";
                    matrica[i][j + 1] = "X";
                }
            }
            
        }
        int brojac = 0;
        for (int i = 0; i < matrica.length; i++) {
            for (int j = 0; j < matrica[0].length; j++) {
                if (matrica[i][j] != "X" || matrica[i][j] != "*") {
                    brojac++;
                }
            }
        }
        for (int i = 0; i < matrica.length; i++) {
            for (int j = 0; j < matrica.length; j++) {
                System.out.print(matrica[i][j]);
            }
            System.out.println("");
        }
        }
        
    }