How Many Files

From printed percentage and count pairs, recover the unique total file count that fits every truncated percentage, or report that several fit.

Medium5MathInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

A file transfer tool prints a status line while it runs. The line shows the percentage of files transferred so far and the number of files transferred so far:

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

The percentage is not exact. The tool cuts it off at the decimal point, so both 1.2% and 1.7% print as 1%. Write PP for the printed percentage, KK for the printed count and FF for the total number of files. Every status line then satisfies P=100K/FP = \lfloor 100K/F \rfloor.

Users asked to see the total as well, so the line should become this:

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

The total cannot always be recovered. Given the status lines printed during one transfer, report the total number of files, or report that more than one total fits.

The tool prints status lines at arbitrary moments. It does not print at fixed intervals, and it does not print once per transferred file. A total FF fits the status lines when F1F \ge 1, every printed count satisfies KFK \le F (the tool never transfers a file that does not exist), and every printed percentage satisfies P=100K/FP = \lfloor 100K/F \rfloor.

Input

The first line contains TT, the number of test cases. Each test case starts with a line containing NN, the number of status lines, followed by NN lines. The ii-th of them contains two integers PiP_i and KiK_i, the percentage and the count printed on that status line. The lines come in chronological order, so within a test case both PiP_i and KiK_i are nondecreasing.

Limits

  • 1T501 \le T \le 50
  • 1N1001 \le N \le 100
  • 0Pi1000 \le P_i \le 100
  • 0Ki10150 \le K_i \le 10^{15}
  • Every test case has at least one total that fits its status lines.
  • When exactly one total fits, that total is at most 101510^{15}.

Output

For each test case, print one line Case #x: y, where xx is the test case number starting from 1 and yy is the total number of files. When more than one total fits the status lines, print -1 in place of yy.