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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Maze {
    static int k, n, m;
    static char[][] maze;
    static Node[][] nodes;
    
    static Graph graph;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] arrayLine = br.readLine().split(" ");
        n = Integer.parseInt(arrayLine[0]);
        m = Integer.parseInt(arrayLine[1]);
        k = Integer.parseInt(arrayLine[2]);
        
        maze = new char[n][m];
        nodes = new Node[n][m];
        graph = new Graph(k + 1);
        
        for (int i = 0; i < n; i++) {
            maze[i] = br.readLine().toCharArray();
        }
        
        mazeToGraph();
        graph.DFS(0);
        
        ArrayList<Integer[]> xes = graph.getIndexes();
        putXes(xes);
        print();
        
    }
    
    private static void putXes(ArrayList<Integer[]> xes) {
        for (Integer[] X : xes) {
            maze[X[0]][X[1]] = 'X';
        }
    }
    
    private static void mazeToGraph() {
        addAllNodes();
        addAllNeighbors();
    }
    
    private static void addAllNodes() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == '.')
                    nodes[i][j] = new Node(i, j);
            }
        }
    }
    
    private static void addAllNeighbors() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (maze[i][j] == '.') {
                    Node node = nodes[i][j];
                    addNeighbors(node);
                    graph.addNode(node);
                }
            }
        }
    }
    
    private static void addNeighbors(Node node) {
        int x = node.getX();
        int y = node.getY();
        addNeighbor(node, x, y - 1);
        addNeighbor(node, x, y + 1);
        addNeighbor(node, x - 1, y);
        addNeighbor(node, x + 1, y);
    }
    
    private static void addNeighbor(Node node, int x, int y) {
        if ((x < n && x >= 0) && (y < m && y >= 0) && maze[x][y] == '.') {
            node.addNeighbor(nodes[x][y]);
        }
    }
    
    public static void print() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                System.out.print(maze[i][j]);
            }
            System.out.println();
        }
    }
}

class Node {
    int x, y, index;
    ArrayList<Node> neighbors;
    
    public Node(int x, int y) {
        this.x = x;
        this.y = y;
        neighbors = new ArrayList<Node>();
    }
    
    public void addNeighbor(Node neighbor) {
        neighbors.add(neighbor);
    }
    
    private String toStringNodeValue() {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        sb.append(index);
        sb.append("]");
        sb.append("(");
        sb.append(x);
        sb.append(", ");
        sb.append(y);
        sb.append(")");
        return sb.toString();
    }
    
    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
    
    public int getIndex() {
        return index;
    }
    
    public void setIndex(int index) {
        this.index = index;
    }
    
    @Override
    public boolean equals(Object obj) {
        Node o = (Node) obj;
        if (x == o.x && y == o.y) return true;
        return false;
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(toStringNodeValue());
        sb.append(" -> ");
        for (Node node : neighbors) {
            sb.append(node.toStringNodeValue());
            sb.append(", ");
        }
        if (neighbors.size() == 0) sb.append("sin vecinos, ");
        String s = sb.toString();
        return s.substring(0, s.length() - 2); 
    }

    public ArrayList<Node> getNeighbors() {
        // TODO Auto-generated method stub
        return neighbors;
    }
}

class Graph {
    ArrayList<Node> nodes;
    ArrayList<Boolean> visit;
    int counter;
    int size;
    
    public Graph(int stop) {
        nodes = new ArrayList<Node>();
        visit = new ArrayList<>();
        counter = stop;
    }
    
    public ArrayList<Boolean> getVisit() {
        // TODO Auto-generated method stub
        return visit;
    }

    public int size() {
        return size;
    }

    public void addNode(Node node) {
        node.setIndex(nodes.size());
        nodes.add(node);
        visit.add(false);
        size++;
    }
    
    public Node find(Node otherNode) {
        for (Node node : nodes) {
            if (node.equals(otherNode)) return node;
        }
        return null;
    }
    
    public void DFS(int node_i) {
        if (size < counter) return;
        if (visit.get(node_i)) return;
        visit.set(node_i, true);
        size--;
        for (Node node : nodes.get(node_i).getNeighbors()) {
            DFS(node.getIndex());
        }
    }
    
    public ArrayList<Integer[]> getIndexes() {
        ArrayList<Integer[]> ret = new ArrayList<>();
        Integer[] pair;
        for (Node node : nodes) {
            if (!visit.get(node.getIndex())) {
                pair = new Integer[2];
                pair[0] = node.getX();
                pair[1] = node.getY();
                ret.add(pair);
            }
        }
        return ret;
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Node node : nodes) {
            sb.append(node.toString());
            sb.append("\n");
        }
        if (nodes.size() == 0) sb.append("sin nodos\n");
        String s = sb.toString();
        return s.substring(0, s.length() - 1);
    }
}