PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000089. Các hồ ở Berland (Lakes in Berland)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Các hồ ở Berland (Lakes in Berland)

Lakes in Berland

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A map is an n×mn\times m grid of water (.) and land (*). Four-directionally connected water cells form a component. A component is a lake only if it does not touch the map boundary; boundary-touching water is connected to the ocean. At least kk lakes exist initially. Convert the fewest water cells to land so exactly kk lakes remain, then output the number changed and the resulting grid.

Input

The first line contains n,m,kn,m,k. The next nn lines each contain exactly mm characters, each . or *.

Output

Print the minimum number of converted cells, followed by the nn resulting grid rows. Any optimal resulting map is accepted.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤81\le n,m\le8; 0≤k≤500\le k\le 50; the original map contains at least kk lakes.
  • Subtask 2 (30 points): 1≤n,m≤251\le n,m\le25; 0≤k≤500\le k\le50; the original map contains at least kk lakes.
  • Subtask 3 (50 points): 1≤n,m≤501\le n,m\le50; 0≤k≤500\le k\le50; the original map contains at least kk lakes.

Examples

Input

5 4 1
****
*..*
****
**.*
..**

Output

1
****
*..*
****
****
..**

Explanation

The two water cells in row 22 form a lake of size 22. The isolated water cell in row 44 forms a lake of size 11. The bottom-row water touches the boundary and is not a lake. Filling the one-cell lake leaves exactly one lake at a cost of 11.