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.DataInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

/**
 * Created by prd on 12/29/13.
 */
public class C
{
    private static final int N = 505;
    static char[][] grid = new char[N][N];

    static int row, colomn, nWalls;
    static int dx[]= new int[4];
    static int dy[]= new int[4];
    private static int[][] Dist = new int [N][N];


    public static class Pair <E,V> {
        E first;
        V second;
        public Pair (E first, V second) {
            this.first = first;
            this.second = second;
        }
    }

    public static  void main(String[]args) throws Exception
    {
        dx[0]=0; dx[1]=1; dx[2]=0; dx[3]=-1;
        dy[0]=1; dy[1]=0; dy[2]=-1; dy[3]=0;

        Parser pr=new Parser(System.in);
        PrintWriter out=new PrintWriter(System.out);

        row = pr.ni();
        colomn = pr.ni();
        nWalls = pr.ni();

        for (int i = 0; i < row; i++) {
            grid[i] = pr.ns().toCharArray();
        }

        int starti = 0;
        int startj = 0;

        for (int i = 0; i < row; i++) {
            for (int j = 0; j < colomn; j++) {
                if (grid[i][j] == '.') {
                    starti = i;
                    startj = j;
                    break;
                }
            }
        }

        if (nWalls != 0) {
            bfs (starti, startj);

            int maxDistance = 0;
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < colomn; j++) {
                    maxDistance = Math.max (maxDistance, Dist[i][j]);
                }
            }

            int left = nWalls;
            int currentDistance = maxDistance;
            Vector <ArrayList <Pair <Integer,Integer>>> values = new Vector <ArrayList<Pair<java.lang.Integer,java.lang.Integer>>>();
            values.setSize(maxDistance + 1);
            for (int i = 0; i <= maxDistance; i++)
                values.set (i, new ArrayList<Pair<Integer, Integer>>());

            //Map <Integer, Pair<Integer, Integer> > values = new HashMap<Integer, Pair <Integer, Integer> >();
            for (int i = 0; i < row; i++)
                for (int j = 0; j < colomn; j++) {
                    if (grid[i][j] == '.') {
                        //System.out.println (Dist[i][j]);
                        values.get(Dist[i][j]).add (new Pair <Integer, Integer> (i, j));
                    }
                }

            for (int i = maxDistance; i >= 0; i--) {
                for (int j = 0; j < values.get(i).size(); j++) {
                    Pair <Integer, Integer> p = values.get(i).get(j);
                    if (left > 0) {
                        grid[p.first][p.second] = 'X';
                        left --;
                    }
                }
            }
        }

        for (int i = 0; i < row; i++) {
            for (int j = 0; j < colomn; j++)
                out.printf ("%c", grid[i][j]);
            out.println ();
        }

        out.close();
    }

    private static void bfs(int starti, int startj) {
        Queue<Pair<Integer, Integer> > Q = new LinkedList<Pair<Integer, Integer>>();
        Q.add (new Pair<Integer, Integer> (starti, startj));

        for (int i = 0; i < row; i++)
            for (int j = 0; j < colomn; j++)
                Dist[i][j] = -1;

        Dist[starti][startj] = 0;

        while (!Q.isEmpty()) {
            Pair<Integer, Integer> from = Q.element();
            Q.remove();

            for (int d = 0; d < 4; d++) {
                int newi = from.first + dx[d];
                int newj = from.second + dy[d];

                if (valid (newi, newj) && grid[newi][newj] == '.') {
                    if (Dist[newi][newj] == -1) {
                        Q.add (new Pair<Integer, Integer> (newi, newj));
                        Dist[newi][newj] = Dist[from.first][from.second] + 1;
                    }
                }
            }
        }
    }

    private static boolean valid(int x, int y) {
        if (x >= 0 && x < row && y >= 0 && y < colomn)
            return true;
        else
            return false;
    }


    private static class Parser
    {
        final private int BUFFER_SIZE = 1 << 16;

        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Parser(InputStream in)
        {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public int ni() throws Exception
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = c == '-';
            if (neg) c = read();
            do
            {
                ret = ret * 10 + c - '0';
                c = read();
            } while (c > ' ');
            if (neg) return -ret;
            return ret;
        }

        public long nl() throws Exception
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = c == '-';
            if (neg) c = read();
            do
            {
                ret = ret * 10 + c - '0';
                c = read();
            } while (c > ' ');
            if (neg) return -ret;
            return ret;
        }

        public String ns() throws Exception
        {
            StringBuffer ret=new StringBuffer();
            byte c = read();
            while (c <= ' ') c = read();
            do
            {
                ret = ret.append((char)c);
                c = read();
            } while (c > ' ');
            return ret.toString();
        }

        private void fillBuffer() throws Exception
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws Exception
        {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }
    }
}