F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Pop the Balloons

Time Limit: 7000/7000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 673    Accepted Submission(s): 229


Problem Description
Recently, an interesting balloon-popping game can be commonly found near the streets. The rule of this game is quite simple: some balloons are tied to cells of an $n \times m$ lattice, and you are allowed to throw $k$ darts to prick the balloons. The more balloons you pierce, the more incredible prize you will get.

Probably because too many people have got bored with this childish game, a new variation of the game has appeared. In this variation, the balloons are replaced with more powerful ones: when a balloon explodes, strong gusts travel in four directions, blowing away all remaining balloons in the same row and column. In order to reduce the difficulty, not all cells are filled with a balloon.

For example, if you prick the yellow balloon in the following figure, then the red balloons will be blown away, with only the blue balloon remaining.



Now, you are given $k$ darts. Since you are a good dart player that you can precisely throw it to any position you want, it is easy for you to use these $k$ darts to clear all balloons (either by directly pricking, or by blowing away by other exploded balloons). Now you begin to consider: for every $1 \leq x \leq k$, how many different ways are there to clear all balloons with exactly $x$ darts? Two ways are considered different if and only if there exists $i$, such that the positions of $i$-th pricked balloons differ. Note that you cannot throw the dart to an empty cell.
 

Input
The first line of input is a single integer $T$ $(1 \leq T \leq 100)$, denoting the number of test cases.

Each test case begins with a line of three integers $m, n$ $(1 \leq m \leq 12, 1 \leq n \leq 20)$, denoting the size of the balloon lattice, and $k$ $(1 \leq k \leq 20)$, denoting the number of darts. The next $m$ lines, each containing $n$ characters, describe the balloon lattice. Each character is either $\texttt{'Q'}$, which denotes a balloon, or $\texttt{'.'}$, which denotes an empty cell.
 

Output
For each test case, display $k$ lines. The $i$-th line is a single integer denoting the number of different ways of clearing all balloons with exactly $i$ darts.
 

Sample Input
4 2 2 2 QQ .Q 2 2 2 QQ .. 3 3 3 .Q. QQQ .Q. 1 3 1 Q.Q
 

Sample Output
1 2 2 0 1 8 0 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-24 15:15:29, Gzip enabled