Apple's interest

Time Limit: 1000 ms

Memory Limit: 65535 ms

Description

Apple is one of smart boys in my roommates.From his name,we may know he likes computer science.He often finds a vast majority of interesting things about binary numbers.Please look at the following example:
10   10101010
01   01010101
      10101010
      01010101
(A)  (B)
Do you find something in common between matrix A and matrix B ? Yes,Apple finds that matrix B results from matrix A after copying many times.Now you know matrix B,can you tell me the the smallest matrix A? For example:
1010  10  10
1010        10
1010
(B)     (C)   (D)
the smallest matrix A is matrix C,not matrix D.

Input

The first line contains an integer t ( 1 <= t <= 10 ): the number of test cases. Then for each test case:The first line contains two integers n,m ( 1 <= n,m <= 1000 ),where n,m is the size of matrix B.Next n lines contain the informations of the matrix B,which only consists of '0' and '1'.

Output

For each test case, output the result in the form of sample.You should print the case number and the size of smallest matrix A and the information of smallest matrix A.

Sample Input

1
3 4
1010
1010
1010

Sample Output

Case 1:
1 2
10

Hint

None

Source

陶翔专场练习赛

提交代码