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.*;
import java.util.*;

public class maze
{
	

	
	public cell[][] bfs(char [][] maze , cell [][] grid, cell s, int k, int m, int n, int free)
	{
		Queue<cell> q = new LinkedList<cell>();
		q.add(s);
		grid[s.returnX()][s.returnY()].assignVisited(1);
		int c = 1;
		while ((!q.isEmpty())&&(c != free-k))
		{
			cell top = q.peek();
			
			if ((top.returnY()+1 < m)&&(top.returnX()<n)&&(grid[top.returnX()][top.returnY()+1].returnV() != 1)&&(maze[top.returnX()][top.returnY()+1]!='#'))
				{
				grid[top.returnX()][top.returnY()+1].assignVisited(1);
				q.add(grid[top.returnX()][top.returnY()+1]);
				c=c+1; 
				//System.out.println(c+"c");
				if (c == (free - k)) 
					return grid;
				}
			
			if ((top.returnX()+1 < n)&&(top.returnY()<m)&&(grid[top.returnX()+1][top.returnY()].returnV() != 1)&&(maze[top.returnX()+1][top.returnY()]!='#'))
				{
				grid[top.returnX()+1][top.returnY()].assignVisited(1); 
				q.add(grid[top.returnX()+1][top.returnY()]);
				c=c+1; 
				//System.out.println(c+"c");
				if (c == (free - k) )
					return grid;
				}
			
			if ((top.returnY()-1 >= 0)&&(top.returnX()<n)&&(grid[top.returnX()][top.returnY()-1].returnV() != 1)&&(maze[top.returnX()][top.returnY()-1]!='#'))
				{
				grid [top.returnX()][top.returnY()-1].assignVisited(1); 
				q.add(grid[top.returnX()][top.returnY()-1]);
				c=c+1;
				//System.out.println(c+"c");
				if (c == (free - k))
					return grid;
				}
			
			if ((top.returnX()-1 >= 0)&&(top.returnY()<m)&&(grid[top.returnX()-1][top.returnY()].returnV() != 1)&&(maze[top.returnX()-1][top.returnY()]!='#'))
				{
				grid [top.returnX()-1][top.returnY()].assignVisited(1);
				q.add(grid[top.returnX()-1][top.returnY()]);
				c=c+1;
				//System.out.println(c+"c");
				if (c == (free - k) )
					return grid;
				}
			
			q.remove();
			
			
		}
		return grid;
	}
	
	
	
	
	
	
	public static void main(String args[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		maze mz = new maze();
		
		String[] nums = br.readLine().split(" ");
		int n = Integer.parseInt(nums[0]);
		int m = Integer.parseInt(nums[1]);
		int k = Integer.parseInt(nums[2]);
		
		char[][] maze = new char[n][m];
		cell [][] grid = new cell [n][m];
		
		for (int i = 0; i< n; i++)
			maze[i] = br.readLine().toCharArray();
		
		
		
		cell s = new cell();
		int free = 0;
		for (int i = 0; i< n; i++)
		{
			for (int j = 0; j< m; j++)
			{
				grid[i][j] = new cell().assignCell(i, j);
				if (maze[i][j] == '.')
					{s.assignCell(i, j);free++;}
			}
		}
		//System.out.println(free+" "+ k);
		cell [][] final_grid = mz.bfs(maze, grid, s, k, m, n, free);
		
		for (int i = 0; i< n; i++)
		{
			StringBuilder ans = new StringBuilder();
			for (int j = 0; j< m; j++)
			{
				if ((final_grid[i][j].returnV() == 0)&&(maze[i][j] == '.'))
					ans.append('X');
				else if (maze[i][j] == '#')
					ans.append('#');
				else 
					ans.append('.');
			}
			System.out.println(ans.toString().trim());
		}
		
	//	System.out.println();
		//System.out.println(s.returnX()+" "+ s.returnY());
		/*for (int i = 0; i< n; i++)
			{
				for (int j = 0; j< m; j++)
					System.out.print(final_grid[i][j].returnV()+" ");
				System.out.println();
			}*/
	
		
	}
}

class cell
{
	private int x;
	private int y;
	private int visited;
	
	cell()
	{
		x = 0;
		y = 0;
		visited = 0;
	}
	
	cell assignCell(int xi, int yi)
	{
		x = xi;
		y = yi;
		return this;
	}
	
	void assignVisited(int v)
	{
		visited = v;
	}
	
	int returnX()
	{
		return x;
	}
	int returnY()
	{
		return y;
	}
	int returnV()
	{
		return visited;
	}
	
	
}