Problem: Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.

Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any other one. Pavel doesn't like it when his maze has too little walls. He wants to turn exactly k empty cells into walls so that all the remaining cells still formed a connected area. Help him.

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 500, 0 ≤ k < s), where n and m are the maze's height and width, correspondingly, k is the number of walls Pavel wants to add and letter s represents the number of empty cells in the original maze.

Each of the next n lines contains m characters. They describe the original maze. If a character on a line equals ".", then the corresponding cell is empty and if the character equals "#", then the cell is a wall.

Output

Print n lines containing m characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#").

It is guaranteed that a solution exists. If there are multiple solutions you can output any of them.

Examples

Input

3 4 2
#..#
..#.
#...


Output

#.X#
X.#.
#...


Input

5 4 5
#...
#.#.
.#..
...#
.#.#


Output

#XXX
#X#.
X#..
...#
.#.#

Solution (in JAVA):

Solution:

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Maze {
	static final int SPACE = 0, WALL = 1, NEW_WALL = 2, FINAL_SPACE = 3;
	static int[][] maze;
	static int remove, r, c, spaces = 0, newNbrs = 0;
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		/*
		try {
			s = new Scanner(new File("input.txt"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		*/
		r = s.nextInt();
		c = s.nextInt();
		remove = s.nextInt();
		maze = new int[r][c];
		int i = 0;
		Stack<Integer[]> nbrs = new Stack<Integer[]>();
		while(s.hasNextLine()){
			String line = s.nextLine();
			if(line.equals("")) continue;
			for(int j = 0; j < c; j++){
				if(line.charAt(j) == '#'){
					maze[i][j] = WALL;
				}else{
					maze[i][j] = SPACE;
					spaces++;
					if(spaces==1){
						nbrs.push(new Integer[]{i,j});
					}
				}
			}
			i++;
		}
		
		if(remove!=0){
			while(newNbrs < spaces - remove && !nbrs.isEmpty()){
				Integer[] curr = nbrs.pop();
				for(Integer[] nbr : getNeighbors(curr[0],curr[1])) nbrs.push(nbr);
			}			
			
			for(int j = 0; j < r; j++){
				for(int k = 0; k < c; k++){
					String val = "";
					if(maze[j][k] == WALL) val = "#";
					else if(maze[j][k] == SPACE) val = "X";
					else if(maze[j][k] == FINAL_SPACE) val = ".";
					System.out.print(val);
				}
				System.out.println("");
			}
		}else{
			for(int j = 0; j < r; j++){
				for(int k = 0; k < c; k++){
					String val = "";
					if(maze[j][k] == WALL) val = "#";
					else if(maze[j][k] == SPACE) val = ".";
					System.out.print(val);
				}
				System.out.println("");
			}
		}
		
		

	}
	
	private static ArrayList<Integer[]> getNeighbors(int r, int c){
		if(maze[r][c] == SPACE && newNbrs < spaces - remove){
			maze[r][c] = FINAL_SPACE;
			newNbrs++;
		}
		int top = (r==0)? -1 : r-1;
		int bottom = (r==maze.length-1)? -1 : r+1;
		int left = (c==0)? -1 : c-1;
		int right = (c==maze[r].length-1)? -1 : c+1;
		
		int neighbors[][] = {
				{top,c},
			{r,left},{r,right},
				{bottom,c}};
		ArrayList<Integer[]> nbrs = new ArrayList<Integer[]>();
		for(int i = 0; i < neighbors.length; i++){
			if(neighbors[i][0] == -1 || neighbors[i][1] == -1) continue;
			if(maze[neighbors[i][0]][neighbors[i][1]] == SPACE && newNbrs < spaces - remove){
				maze[neighbors[i][0]][neighbors[i][1]] = FINAL_SPACE;
				nbrs.add(new Integer[]{neighbors[i][0],neighbors[i][1]});
				newNbrs++;
			}
		}
		return nbrs;
	}
}