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

public class feb20 {

//	            ***                          ++                      
//             +=-==+                      +++=-                     
//            +-:---==+                   *+=----=                   
//           +-:------==+               ++=------==                  
//           =-----------=++=========================                
//          +--:::::---:-----============-=======+++====             
//          +---:..:----::-===============-======+++++++++           
//          =---:...---:-===================---===++++++++++         
//          +----:...:-=======================--==+++++++++++        
//          +-:------====================++===---==++++===+++++      
//         +=-----======================+++++==---==+==-::=++**+     
//        +=-----================---=======++=========::.:-+*****    
//       +==::-====================--:  --:-====++=+===:..-=+*****   
//       +=---=====================-...  :=..:-=+++++++++===++*****  
//       +=---=====+=++++++++++++++++=-:::::-====+++++++++++++*****+ 
//      +=======++++++++++++=+++++++============++++++=======+****** 
//      +=====+++++++++++++++++++++++++==++++==++++++=:...  . .+**** 
//     ++====++++++++++++++++++++++++++++++++++++++++-.     ..-+**** 
//     +======++++++++++++++++++++++++++++++++===+====:.    ..:=++++ 
//     +===--=====+++++++++++++++++++++++++++=========-::....::-=++* 
//     ====--==========+++++++==+++===++++===========--:::....:=++*  
//     ====---===++++=====++++++==+++=======-::--===-:.  ....:-+++   
//     ==--=--====++++++++==+++++++++++======--::::...::::::-=+++    
//     ===----===++++++++++++++++++++============--=-==----==+++     
//     =--------====++++++++++++++++=====================+++++++     
//     =---------=======++++++++====+++=================++++++++     
//     -----------========+++++++++++++++=================+++++++    
//     =----------==========++++++++++=====================++++++++  
//     =====------==============+++++++===================+++==+++++ 
//     =======------==========================================++++++

	// created by : Nitesh Gupta
	public static void main(String[] args) throws Exception {

//		first();
//		sec();
		third();
//		four();
//			fif();
// 		six();

	}

	private static void first() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(scn[0]);
		int k = Integer.parseInt(scn[1]) - 1;
		long[] arr = new long[n];
		scn = (br.readLine()).trim().split(" ");
		for (int i = 0; i < n - 1; i++) {
			arr[i] = Long.parseLong(scn[i]);
		}
		long i = 0;
		boolean can = false;
		while (i < n - 1) {
			if (i == k) {
				can = true;
				break;
			}
			i = i + arr[(int) i];
		}
		if (can || i == k) {
			sb.append("YES");
		} else {
			sb.append("NO");
		}
		System.out.println(sb);
		return;

	}

	private static void sec() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		int t = Integer.parseInt(scn[0]);
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			int[] arr = new int[n];
			scn = (br.readLine()).trim().split(" ");
			for (int i = 0; i < n; i++) {
				arr[i] = (int) Long.parseLong(scn[i]);
			}
			boolean[] vis = new boolean[n];
			LinkedList<pair> q = new LinkedList<>();
			q.add(new pair(0, 0));
			int ans = -1;
			while (!q.isEmpty()) {
				pair rp = q.removeFirst();
				if (arr[rp.pos] == 0) {
					ans = rp.c;
					break;
				}
				if (vis[rp.pos])
					continue;
				vis[rp.pos] = true;

				int f = rp.pos + arr[rp.pos];
				if (f < n) {
					q.add(new pair(f, rp.c + 1));
				}
				int b = rp.pos - arr[rp.pos];
				if (b >= 0) {
					q.add(new pair(b, rp.c + 1));
				}
			}
			sb.append(ans + "\n");
		}
		System.out.println(sb);
		return;
	}

	static class pair {
		int pos, c;

		pair(int a, int b) {
			pos = a;
			c = b;
		}
	}

	private static void third() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(scn[0]);
		int m = Integer.parseInt(scn[1]);
		int k = Integer.parseInt(scn[2]);
		int[][] arr = new int[n][m];
		int x = -1, y = -1;
		int empty = 0;
		for (int i = 0; i < n; i++) {
			String str = br.readLine();
			for (int j = 0; j < m; j++) {
				if (str.charAt(j) == '#') {
					arr[i][j] = 1;
				} else {
					if (x == -1)
						x = i;
					if (y == -1)
						y = j;
					empty += 1;
				}
			}
		}
		count = 0;
		dfs(arr, new boolean[n][m], x, y, n, m, empty - k);
		for (int[] a : arr) {
			for (int ele : a) {
				if (ele == 0)
					sb.append('.');
				if (ele == 1)
					sb.append('#');
				if (ele == 2)
					sb.append('X');

			}
			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void dfs(int[][] arr, boolean[][] vis, int x, int y, int n, int m, int k) {
		vis[x][y] = true;
		int[] col = { -1, 1, 0, 0 };
		int[] row = { 0, 0, 1, -1 };
		for (int i = 0; i < 4; i++) {
			int nx = x + row[i];
			int ny = y + col[i];
			if (nx < 0 || nx > n - 1 || ny < 0 || ny > m - 1 || arr[nx][ny] == 1 || vis[nx][ny])
				continue;
			count += 1;
			if (count >= k) {
				arr[nx][ny] = 2;
			}
			dfs(arr, vis, nx, ny, n, m, k);

		}

	}

	static

	int count;

	private static void four() throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(scn[0]);
		int k = Integer.parseInt(scn[1]);
		int[] arr = new int[n];
		scn = (br.readLine()).trim().split(" ");
		for (int i = 0; i < n; i++) {
			arr[i] = (int) Long.parseLong(scn[i]);
		}
		ArrayList<ArrayList<Integer>> list = new ArrayList<>();
		for (int i = 0; i <= n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < n; i++) {
			list.get(arr[i]).add(i + 1);
		}
		boolean pos = true;
		if (list.get(0).size() != 1) {
			pos = false;
		} else {
			ArrayList<Integer> ans = new ArrayList<>();
			boolean zero = false;
			for (int i = 1; i < n; i++) {
				ArrayList<Integer> prev = list.get(i - 1);
				ArrayList<Integer> curr = list.get(i);
				if (curr.size() == 0) {
					zero = true;
					continue;
				}
				if (zero) {
					pos = false;
					break;
				}
				int j = 0;
				for (int x = 0; x < prev.size(); x++) {
					int added = 0;
					for (; j < curr.size(); j++) {
						ans.add(prev.get(x));
						ans.add(curr.get(j));
						added += 1;
						if (added == k) {
							j += 1;
							break;
						}
						if (added > k) {
							pos = false;

						}
					}
				}
				if (j < curr.size()) {
					pos = false;
					break;
				}
				if (i == 1)
					k -= 1;
			}
			if (pos) {
				sb.append(ans.size() / 2 + "\n");
				for (int i = 0; i < ans.size(); i += 2) {
					sb.append(ans.get(i) + " " + ans.get(i + 1) + "\n");
				}
			}

		}
		if (!pos) {
			sb.append("-1\n");
		}
		System.out.println(sb);
		return;
	}

	private static void fif() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		int t = Integer.parseInt(scn[0]);
		StringBuilder sb = new StringBuilder();

		while (t-- > 0) {
			scn = (br.readLine()).trim().split(" ");
			int n = Integer.parseInt(scn[0]);
			long[] arr = new long[n];
			scn = (br.readLine()).trim().split(" ");
			for (int i = 0; i < n; i++) {
				arr[i] = Long.parseLong(scn[i]);
			}

			sb.append("\n");
		}
		System.out.println(sb);
		return;
	}

	private static void six() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] scn = (br.readLine()).trim().split(" ");
		StringBuilder sb = new StringBuilder();

		int n = Integer.parseInt(scn[0]);
		int m = Integer.parseInt(scn[1]);
		int[] par = new int[n + 1];
		par[0] = -1;
		wish = new int[n + 1];
		wish[0] = -1;
		for (int i = 0; i < m; i++) {
			scn = (br.readLine()).trim().split(" ");
			int x = Integer.parseInt(scn[0]);
			int y = Integer.parseInt(scn[1]);
			par[y] = x;
		}
		scn = (br.readLine()).trim().split(" ");

		for (int i = 0; i < n; i++) {
			wish[i + 1] = Integer.parseInt(scn[i]);
		}
		int[][] ch = parentToChildren(par);
		dq = new ArrayDeque<>();
		if (dfs(0, ch, par)) {
			System.out.println(dq.size());
			for (int x : dq) {
				System.out.println(x);
			}
		} else {
			System.out.println(-1);
		}
		return;
	}

	static int[] wish;

	static boolean dfs(int cur, int[][] ch, int[] par) {
		if (cur > 0) {
			if (wish[cur] == wish[par[cur]]) {
				dq.addLast(cur);
			} else if (wish[cur] == cur) {
				dq.addFirst(cur);
			} else {
				return false;
			}
		}
		for (int e : ch[cur]) {
			if (!dfs(e, ch, par))
				return false;
		}
		return true;
	}

	static Deque<Integer> dq;
	int lp = 0;

	public static int[][] parentToChildren(int[] par) {
		int n = par.length;
		int[] ct = new int[n];
		for (int i = 0; i < n; i++) {
			if (par[i] >= 0) {
				ct[par[i]]++;
			}
		}
		int[][] g = new int[n][];
		for (int i = 0; i < n; i++) {
			g[i] = new int[ct[i]];
		}
		for (int i = 0; i < n; i++) {
			if (par[i] >= 0) {
				g[par[i]][--ct[par[i]]] = i;
			}
		}

		return g;
	}

	public static void sort(long[] arr) {
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			int idx = (int) Math.random() * n;
			long temp = arr[i];
			arr[i] = arr[idx];
			arr[idx] = temp;
		}
		Arrays.sort(arr);
	}

	public static void print(long[][] dp) {
		for (long[] a : dp) {
			for (long ele : a) {
				System.out.print(ele + " ");
			}
			System.out.println();
		}
	}

}