Олимпиадный тренинг

Задача 38371. Combination lock


Задача

Темы: Обход в глубину
Company "Castles and Castles" has recently developed a new type of combination lock to be placed on gate locks. The lock panel is a rectangle w cells wide and h cells high. Some of them have buttons.

The code on this lock is entered by simultaneously pressing k buttons. To make the code easier to remember, the buttons used in it should form a cohesive area. An area is called connected if it is possible to get from any cell of the area to any other by moving only between the cells of this area with a common side. An important criterion for the reliability of the lock is the number of different codes that can be dialed on it.

To assess the reliability of locks, you need to write a program to calculate the specified value.

Imprint

The first line of the input file contains three integers h, w and k (1 ≤ h, w ≤ 30; 1 ≤ k ≤ 10). Each of the following h lines contains w characters. The symbol "#" denotes a button, and "." — her absence.

Imprint

In the output file print a single number — the number of codes that meet the specified requirements.
 
Examples
# Input Output
1
2 2 2
.#
##
2
2
5 6 7
.#....
##.##.
..#.#.
.####.
.....#
3