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

문제

Alien tech company G has a very old file transfer tool that is still in use today. While the tool is running, it reassures users by giving status updates on both the percentage of files transferred so far and the number of files transferred so far. The status updates during the process might look like this:

 20% |==>-------|     1 files transferred
100% |==========|     5 files transferred

But the percentage isn't precise; it is simply truncated before the decimal point (i.e. floored to the next lowest or equal 1%). That is, both 1.2% and 1.7% would be displayed as 1%.

Some users may want to know the exact total number of files, so you want to modify the tool so that the status updates look like this:

 20% |==>-------|     1 out of 5 files transferred
100% |==========|     5 out of 5 files transferred

But you've realized that it may or may not be possible to know the number of files. Given the status updates that the tool displays, either figure out how many files there are, or determine that it can't be done (i.e., there are multiple possible values for the number of files). The status updates are not guaranteed to occur at regular intervals and are not guaranteed to occur whenever a file is transferred.

입력

The first line contains T, the number of test cases. T test cases follow. Each test case consists of one line with an integer N, the number of status updates output by the tool, followed by N lines with the format Pi Ki, where Pi and Ki are integers representing the percentage and number of files transferred at some point in the process. The updates are given listed in chronological order -- that is, both the Pi values and the Ki values are nondecreasing throughout a test case.

Limits

  • 1 ≤ T ≤ 50.
  • 1 ≤ N ≤ 100.
  • 0 ≤ Pi ≤ 100
  • 0 ≤ Ki ≤ 1015
  • The answer is guaranteed not to exceed 1015.

출력

For each case, output a line starts with "Case #x: y", where x is the number of the case (starting from 1), and y is either the total number of files, or -1 if that number is ambiguous.

예제 입력 1

3
2
20 1
100 5
10
25 241
27 262
43 407
44 413
57 536
64 601
67 637
84 789
95 893
96 903
10
0 0
8 2
8 2
17 4
30 7
39 9
69 16
73 17
82 19
91 21

예제 출력 1

Case #1: 5
Case #2: -1
Case #3: 23

채점 및 기타 정보

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