시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB0000.000%

문제

Long ago, an alien civilization built a giant monument. The floor of the monument looked like this:

###############
#.............#
#.###########.#
#.#.........#.#
#.#.#######.#.#
#.#.#.....#.#.#
#.#.#.###.#.#.#
#.#.#.#.#.#.#.#
#.#.#.###.#.#.#
#.#.#.....#.#.#
#.#.#######.#.#
#.#.........#.#
#.###########.#
#.............#
###############


Each '#' represents a red tile, and each '.' represents a blue tile. The pattern went on for miles and miles (you may, for the purposes of the problem, assume it was infinite). Today, only a few of the tiles remain. The rest have been damaged by methane rain and dust storms. Given the locations and colours of the remaining tiles, can you find the center of the pattern?

입력

The first line of the input gives the number of test cases, TT test cases follow. Each one starts with a line containing N, the number of remaining tiles. The next N lines each contain XiYi, and the tile colour (either '#' or '.').

Limits

• 1 ≤ T ≤ 50.
• The list of coordinates in each test case will not contain duplicates.
• 1 ≤ N ≤ 1000.
• -1015 ≤ Xi ≤ 1015.
• -1015 ≤ Yi ≤ 1015.

출력

For each test case, output one line containing "Case #c: X Y", where c is the case number (starting from 1) and (XY) is the location of the center of the pattern. If there is more than one possible answer, output the (XY) closest to (0, 0) in Manhattan distance (the distance in x, plus the distance in y). If there are still ties, output the one with the largest X. If there are still ties after that, output the one with the largest Y. If there is no possible answer, output "Case #c: Too damaged".

예제 입력 1

6
1
0 0 .
1
0 0 #
3
0 0 #
0 1 #
1 0 #
5
50 30 #
49 30 #
49 31 #
49 32 #
50 32 #
2
-98 0 #
99 50 .
4
88 88 .
88 89 .
89 88 .
89 89 .


예제 출력 1

Case #1: 0 0
Case #2: 1 0
Case #3: 1 1
Case #4: 50 31
Case #5: 1 0
Case #6: Too damaged


채점 및 기타 정보

• 예제는 채점하지 않는다.