Qualle? Quale?

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=441&page=show_problem&problem=4015 [PDF](https://uva.onlinejudge.org/external/125/p12570.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12570/fdc31066197848eb12e006c56eecd72c14f345fb.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12570/a4a3efcdc68dc11d324afe46774662934e36311f.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12570/1e7ba88dbd511da88306099bfe6d9efdc7f9e2bc.png)

输入输出样例

输入样例 #1

4
5 3
ABC
D-B
CB-
E-E
CA-
3 2
AB
C-
-C
4 4
-A--
BB--
--CC
--D-
3 4
AAAA
BBBB
CCCC

输出样例 #1

Case 1: 12 123
Case 2: -1
Case 3: 23 123 234 1234
Case 4: 1 2 3 4 12 13 14 23 24 34 123 124 134 234