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 PYTHON):

Solution:
firstLine = raw_input().split(' ')
n = int(firstLine[0])
m = int(firstLine[1])
k = int(firstLine[2])
inArray   = [list(raw_input()) for _ in range(0, n)]

openCount = 0
for row in inArray:
    for entry in row:
        if entry == '.':
            openCount += 1

numToLeave = openCount - k
start = None
for row in range(0,n):
    for col in range(0,m):
        if inArray[row][col] == '.':
            start = (row, col)
            break
    if start:
        break

def hasGoodNeighbor(row, col):
    global keepArray
    if row > 0 and keepArray[row - 1][col]:
        return True
    if col > 0 and keepArray[row][col - 1]:
        return True
    if row < n - 1 and keepArray[row + 1][col]:
        return True
    if col < m - 1 and keepArray[row][col + 1]:
        return True
    return False

keepArray = [[False for _ in range(0,m)]for _ in range(0,n)]

if numToLeave != 0:
    keepArray[start[0]][start[1]] = True
    numKept = 1
    dfsStack = [start]
    while numKept < numToLeave:
        top = dfsStack.pop()
        row = top[0]
        col = top[1]
        if row > 0 and inArray[row - 1][col] == '.' and not keepArray[row - 1][col]:
            keepArray[row - 1][col] = True
            numKept += 1
            if numKept == numToLeave:
                break
            dfsStack.append((row - 1, col))
        if col > 0 and inArray[row][col - 1] == '.' and not keepArray[row][col - 1]:
            keepArray[row][col - 1] = True
            numKept += 1
            if numKept == numToLeave:
                break
            dfsStack.append((row, col - 1))
        if row < n - 1 and inArray[row + 1][col] == '.' and not keepArray[row + 1][col]:
            keepArray[row + 1][col] = True
            numKept += 1
            if numKept == numToLeave:
                break
            dfsStack.append((row + 1, col))
        if col < m - 1 and inArray[row][col + 1] == '.' and not keepArray[row][col + 1]:
            keepArray[row][col + 1] = True
            numKept += 1
            if numKept == numToLeave:
                break
            dfsStack.append((row, col + 1))

'''
    numKept = 1
    while numKept < numToLeave:
        for row in range(0,n):
            for col in range(0,m):
                if (inArray[row][col] == '.'
                    and not keepArray[row][col]
                    and hasGoodNeighbor(row, col)):
                    keepArray[row][col] = True
                    numKept += 1
                    if numKept == numToLeave:
                        break
            if numKept == numToLeave:
                break
'''

for row in range(0,n):
    for col in range(0,m):
        if inArray[row][col] == '.' and not keepArray[row][col]:
            inArray[row][col] = 'X'

for row in inArray:
    print "".join(row)

'''
reachableSize = -1

def reachable(row, col):
    visited = [[False for _ in range(0, m)] for _ in range (0, n)]
    visited[row][col] = True
    reached = 1
    if row > 0 and inArray[row - 1][col] == '.':
        reached += visit(row - 1, col, visited)
    if col > 0 and inArray[row][col - 1] == '.':
        reached += visit(row, col - 1, visited)
    if row < n - 1 and inArray[row + 1][col] == '.':
        reached += visit(row + 1, col, visited)
    if col < m - 1 and inArray[row][col + 1] == '.':
        reached += visit(row, col + 1, visited)
    return reached

def visit(row, col, visited):
    if visited[row][col]:
        return 0
    reached = 1
    visited[row][col] = True
    if row > 0 and inArray[row - 1][col] == '.':
        reached += visit(row - 1, col, visited)
    if col > 0 and inArray[row][col - 1] == '.':
        reached += visit(row, col - 1, visited)
    if row < n - 1 and inArray[row + 1][col] == '.':
        reached += visit(row + 1, col, visited)
    if col < m - 1 and inArray[row][col + 1] == '.':
        reached += visit(row, col + 1, visited)
    return reached

def getSize():
    size = 0
    for row in range(0, n):
        for col in range(0, m):
            if inArray[row][col] == '.':
                size = reachable(row, col)
                break
        if size > 0:
            break
    return size

reachableSize = getSize()

#print "I can reach {}.".format(reachableSize)

def end():
    for row in inArray:
        print ''.join(row)
    exit()

def canKill(row, col):
    return isEnd(row, col) or notBreak(row, col)

def isEnd(row, col):
    if inArray[row][col] != '.':
        return False
    count = 0
    if row > 0 and inArray[row - 1][col] == '.':
        count += 1
    if col > 0 and inArray[row][col - 1] == '.':
        count += 1
    if row < n - 1 and inArray[row + 1][col] == '.':
        count += 1
    if col < m - 1 and inArray[row][col + 1] == '.':
        count += 1
    return count == 1

def notBreak(row, col):
    if inArray[row][col] != '.':
        return False
    global reachableSize
    inArray[row][col] = 'X'
    newSize = getSize()
    inArray[row][col] = '.'
    return newSize == reachableSize - 1


def checkNeighbors(row, col):
    global k
    global reachableSize
    if row > 0 and canKill(row - 1, col):
        inArray[row - 1][col] = 'X'
        k -= 1
        reachableSize -= 1
        if k == 0:
            end()
        checkNeighbors(row - 1, col)
    if col > 0 and canKill(row, col - 1):
        inArray[row][col - 1] = 'X'
        k -= 1
        reachableSize -= 1
        if k == 0:
            end()
        checkNeighbors(row, col - 1)
    if row < n - 1 and canKill(row + 1, col):
        inArray[row + 1][col] = 'X'
        k -= 1
        reachableSize -= 1
        if k == 0:
            end()
        checkNeighbors(row + 1, col)
    if col < m - 1 and canKill(row, col + 1):
        inArray[row][col + 1] = 'X'
        k -= 1
        reachableSize -= 1
        if k == 0:
            end()
        checkNeighbors(row, col + 1)

for row in range(0, n):
    for col in range(0, m):
        char = inArray[row][col]
        if char == '.':
            if canKill(row, col):
                inArray[row][col] = 'X'
                k -= 1
                reachableSize -= 1
                if k == 0:
                    end()
                else:
                    checkNeighbors(row, col)
'''