We are planning to arrange a National Collegiate Programming Contest in Bangladesh. But one of the problems is that members from different teams can discuss with each other if the security is not tight. And this fact sometimes affects the contest rank list. Even if we seize the electronic devices from the team members; there are other ways to communicate. So, our target is to make a site that is fair. The site can be modeled as an M x N grid, where M is the number of rows, and N is the number of columns.
Three kinds of cells are there 1) a blank space, 2) a wall, 3) a reserved space. Teams can only be placed in blank spaces, but at most one team can be placed in one blank space. Team members are not allowed to move from their current place, but they can see through the blank or reserved spaces, but not through walls. And they can see vertically or horizontally. To be more specific two members can communicate if they are in the same row (or column) and there is no wall between them in that row (or column) (like a chess rook). As we have already discussed that we don't want members of different teams to communicate, we want to place teams in the grid such that there is no way for the members of two different teams to communicate with each other.
So, we are assigning this task to you, providing you the information of the grid, your task is to find the maximum number of teams we can place in the grid, so that we can put extra efforts on the problem set. You have to find a valid placement of teams. As there can be many solutions with maximum number of teams, any valid one will do.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing two integers M (1 ≤ M ≤ 100) and N (1 ≤ N ≤ 100). Each of the next M lines contains N characters denoting the grid. There will be three kinds of characters. A .
denotes a blank space, a W
denotes a wall and an R
denotes a reserved space.
Output
For each case, print the case number and the total number of teams in a line. Then print the grid using the same format as in input and report the team cells with T
.
Sample
Sample Input | Sample Output |
---|---|
2 3 5 .RRR. WWWWW .RRR. 3 5 ..RR. .W.RW .RRR. | Case 1: 2 TRRR. WWWWW TRRR. Case 2: 4 .TRR. TWTRW .RRRT |
Notes
This is a special judge problem, wrong output format may cause 'wrong answer'.