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.*;
import java.math.BigInteger;
import java.math.BigDecimal;
 
public class SamGraphs_E {
   
    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    
    List<Integer>[] head;
    int[] vis;
    int n, m, k, s;
    int[][] matr; 
    int cnt;
    HashSet<Integer> labs;
    
    void solve() throws IOException {
    	n = readInt();
    	m = readInt();
    	k = readInt();
    	s = 88;
    	cnt = 0;
    	
    	matr = new int[n+1][m+1];
    	
    	for (int i = 0; i <= n; ++i) {
    		matr[i][0] = '#';
    	}
    	
    	for (int i = 0; i <= m; ++i) {
    		matr[0][i] = '#';
    	}
    	
    	for (int i = 1; i <= n; ++i) {
    		for (int j = 1; j <= m; ++j) {
    			char c = '\n';
    			while ((c == '\n' || c == '\r') && in.ready()) {
    				c = (char) in.read();
    			}
    			
    			if (c == '.') {
    				++s;
    				matr[i][j] = s;
    			} else {
    				matr[i][j] = c;
    			}
    		}
    	}
    	
    	head = new List[s+1];
    	vis = new int[s+1];
    	labs = new HashSet<Integer>();
    	
    	for (int i = 89; i <= s; ++i) {
    		head[i] = new ArrayList<Integer>();
    	}
    	
    	
    	
    	int i = 89;
    	while (i <= s) {
    		labs.add(i);
    		++i;
    	}
    	
    	
    	for (i = 1; i <= n; ++i) {
    		for (int j = 1; j <= m; ++j) {
    			if (matr[i][j] != '#') {
    				if (matr[i-1][j] != '#') {
    					add(matr[i][j], matr[i-1][j]);
    					add(matr[i-1][j], matr[i][j]);
    				}
    				
    				if (matr[i][j-1] != '#') {
    					add(matr[i][j], matr[i][j-1]);
    					add(matr[i][j-1], matr[i][j]);
    				}
    			}
    		}
    	}
    	
    	dfs(89);
    	
    	for (i = 1; i <= n; ++i) {
    		for (int j = 1; j <= m; ++j) {
    			if (labs.contains(matr[i][j])) {
    				matr[i][j] = 'X';
    			}
    		}
    	}
    	
    	for (i = 1; i <= n; ++i) {
    		for (int j = 1; j <= m; ++j) {
    			if (matr[i][j] != '#' && matr[i][j] != 'X') {
    				matr[i][j] = '.';
    			}
    			out.print((char)matr[i][j]);
    		}
    		out.println();
    	}
    }
        
////////// Methods ///////////////////////////////////////////////////////////////////////////    
    
    void dfs(int u) {
    	vis[u] = 1;
    	if (cnt < s-88-k) {
    		++cnt;
    		labs.remove(u);
    	}
    	
    	for (int i = 0; i < head[u].size(); ++i) {
    		if (vis[head[u].get(i)] == 0) {
    			dfs(head[u].get(i));
    		}
    	}
    }
    
    void add(int u, int v) {
    	head[u].add(v);
    }
    
    int min(int... a) {
    	int min = Integer.MAX_VALUE;
    	
    	for (int i = 0; i < a.length; ++i) {
    		if (min > a[i]) {
    			min = a[i];
    		}
    	}
    	
    	return min;
    }
    
    int max(int... a) {
    	int max = Integer.MIN_VALUE;
    	
    	for (int i = 0; i < a.length; ++i) {
    		if (max < a[i]) {
    			max = a[i];
    		}
    	}
    	
    	return max;
    }
    
//////// #Methods //////////////////////////////////////////////////////////////////////////////////////////////////
    
/////// Classes //////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    class Pair implements Comparable<Pair> {
    	long x;
    	long y;
    	
    	Pair() {
    		this.x = 0;
    		this.y = 0;
    	}
    	
    	Pair(long x, long y) {
    		this.x = x;
    		this.y = y;
    	}
    	
    	@Override
    	public boolean equals(Object obj) {
    		if (this == obj) {
    			return true;
    		}
    		if (obj == null) return false;
    		Pair other = (Pair) obj;
    		if (this.x == other.x && this.y == other.y) {
    			return true;
    		}
    		return false;
    	}
    	
    	@Override
    	public int compareTo(Pair other) {
    		if (this.x != other.x) return Long.compare(this.x, other.x);
    		return Long.compare(this.y*other.x, this.x*other.y);
    	}
    }
    
////// #Classes ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
/////// Initialization ////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    public static void main(String[] args) {
        new SamGraphs_E().run();
    }
   
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
   
    void init() throws FileNotFoundException {
      
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("D:\\Java-programs\\eclipse-workspace\\OLYMP\\src\\input.txt"));
            out = new PrintWriter("D:\\Java-programs\\eclipse-workspace\\OLYMP\\src\\output.txt");
        }
       
        tok = new StringTokenizer("");
    }
   
    void run() {
        try {
            long timeStart = System.currentTimeMillis();
           
            init();
            solve();
           
            out.close();
           
            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeStart));
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }
   
    String readLine() throws IOException {
        return in.readLine();
    }
   
    String delimiter = " ";
   
    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) return null;
           
            tok = new StringTokenizer(nextLine);
        }
       
        return tok.nextToken(delimiter);
    }
   
    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
   
    long readLong() throws IOException {
        return Long.parseLong(readString());
    }
    
    double readDouble() throws IOException {
    	return Double.parseDouble(readString());
    }       
}

////////// #Initialization //////////////////////////////////////////////////////////////////////////////////////