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

문제

Vincenzo decides to make cube IV but only has the budget to make a square maze. Its a perfect maze, every room is in the form of a square and there are 4 doors (1 on each side of the room). There is a big number written in the room. A person can only move from one room to another if the number in the next room is larger than the number in his current room by 1. Now, Vincenzo assigns unique numbers to all the rooms (1, 2, 3, .... S2) and then places S2 people in the maze, 1 in each room where S is the side length of the maze. The person who can move maximum number of times will win. Figure out who will emerge as the winner and the number of rooms he will be able to move.

입력

The first line of the input gives the number of test cases, T.  T test cases follow. Each test case consists of S which is the side length of the square maze. Then S2 numbers follow like a maze to give the numbers that have been assigned to the rooms.

1 2 9
5 3 8
4 6 7

출력

For each test case, output one line containing "Case #x: r d", where x is the test case number (starting from 1), r is the room number of the person who will win and d is the number of rooms he could move. In case there are multiple such people, the person who is in the smallest room will win.

제한

  • 1 ≤ T ≤ 100.
  • 1 ≤ S ≤ 103.

예제 입력 1

2
2
3 4
1 2 


3
1 2 9 
5 3 8 
4 6 7 

예제 출력 1

Case #1: 1 2
Case #2: 6 4

채점 및 기타 정보

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