# Display Problem

Nut and Boltu want to buy a LCD display. They went to the market to buy the display. The salesman showed them different types of displays. But he did not tell them the size of the displays. He only showed them the letter 8 printed in the display. Being very inexperienced about LCD displays Nut and Boltu wants your help to find the dimension of the display board. There are some bad displays too. You need to find them as well. A display can be represented as a rectangular grid of some special characters. A good display is a display in which 8 is printed in a way so that the display has a degree. The degree of a display is a positive integer D such that:

1. The number of rows of the grid is 2D + 3.
2. The number of columns of the grid is D + 2.
3. In 0-th row (0-based): the 0-th column and (D + 1)-th column contains dot(.) and other columns contain hyphens(-).
4. In (D + 1)-th row (0-based): the 0-th column and (D + 1)-th column contains dot(.) and other columns contain hyphens(-).
5. In (2D + 2)-th row(0-based): the 0-th column and (D + 1)-th column contains dot(.) and other columns contain hyphens(-).
6. In every other row: the 0-th column and (D + 1)-th column contains bar(|) and other columns contain dot(.). Input First line of the input contains the number of test cases, T (T ≤ 50). In each test case i-th line contains i-th row of the grid that defines the display. A line containing only an asterisk(*) marks the end of test case. Grid will contain only characters dot(.), bar(|) and hyphen(-). There will be at most 25 lines in each test case and a single line will be non-empty and contain at most 30 characters. There will be at least one line in every test case. Output For each input, print the output in the format, ‘Case X: Y ’ (here X is the serial of the input and Y is the degree of the grid if the display is good otherwise print ‘Bad’). Sample Input 2 .---. |...| |...| |...| .---. |...| |...|

2/2 |...| .---.

.---. |...| |...| |...| .---. |...| |...| .---.

Sample Output Case 1: 3 Case 2: Bad