|
It's dinner time! A group of **N** Foxen are standing silently in a field, |
|
which can be represented as an infinite number line, patiently waiting for |
|
their meals to make an appearance. The _i_th Fox is standing at position |
|
**Pi**, with no two Foxen standing at the same position. There's also one hole |
|
in the ground at each each integral position on the number line. Each of these |
|
holes is the entrance to a mole's den, and the Foxen know that some of these |
|
delicious critters are bound to show up sooner or later! |
|
|
|
A little-known fact about Foxen is that, in addition to having an acute array |
|
of regular senses, they possess a SONAR-like ability to emit imperceptible |
|
sound waves and use them to discern objects at great distances. The _i_th Fox |
|
has tuned their wavelength to a distance of **Ri**, allowing them to only |
|
detect moles which emerge from holes at a distance of exactly **Ri** away from |
|
them (that is, at either position **Pi** \- **Ri** or **Pi** \+ **Ri**). |
|
|
|
All of a sudden, some number of moles have just popped up from various holes |
|
all at once! No mole popped up at any Fox's position, no two moles popped up |
|
from the same hole, and every mole was detected by at least one Fox. |
|
Furthermore, each Fox _i_ has determined that there's _exactly_ 1 mole at a |
|
distance of **Ri** away from it (as opposed to there being either 0 or 2 such |
|
moles). |
|
|
|
Following this initial event, there's been quite some commotion. Some moles |
|
may have retreated back underground, and some new moles may have emerged, all |
|
in any order. At every point in time, the set of moles on the surface is |
|
subject to all of the same restrictions as before, with one difference: Each |
|
Fox _i_ continues to be sure that _at least_ 1 mole is still present at a |
|
distance of **Ri** away from it, but can no longer determine whether or not |
|
there are perhaps now 2 such moles instead. |
|
|
|
After some time of this, the Foxen have decided that they're ready to pounce |
|
and "invite" some of the moles currently on the surface over for dinner. |
|
Unfortunately, they've started to become rather overwhelmed with trying to |
|
keep track of which moles may be on the surface, or even roughly how many of |
|
them there might be. Assuming that the Foxen's initial observations were |
|
correct, and that some unknown amount of time has since gone by with moles |
|
surfacing or departing, please help the Foxen determine the number of |
|
different quantities of moles which could possibly have ended up on the |
|
surface. |
|
|
|
If it's impossible for their set of initial observations to have been accurate |
|
in the first place, output -1 instead. |
|
|
|
### Input |
|
|
|
Input begins with an integer **T**, the number of different fields. For each |
|
field, there is first a line containing the integer **N**. Then **N** lines |
|
follow, the _i_th of which contains the space-separated integers **Pi** and |
|
**Ri**. |
|
|
|
### Output |
|
|
|
For the _i_th field, print a line containing "Case #**i**: " followed by a |
|
single integer, the number of different quantities of moles which could |
|
possibly end up on the surface at any point, or -1 if the Foxen's initial |
|
observations must have been inaccurate. |
|
|
|
### Constraints |
|
|
|
1 ≤ **T** ≤ 30 |
|
1 ≤ **N** ≤ 5,000 |
|
0 ≤ **Pi** ≤ 1,000,000,000 |
|
1 ≤ **Ri** ≤ 1,000,000,000 |
|
|
|
### Explanation of Sample |
|
|
|
In the first case, it's possible for there to eventually be 1 mole (at either |
|
position -1 or 1), or 2 moles (at both positions -1 and 1). There can't be 0 |
|
moles due to the restriction that the Fox must detect at least 1 of them, and |
|
there can't be more than 2 moles as they'd have to be at positions which the |
|
Fox is unable to detect. |
|
|
|
In the third case, it's impossible for a set of moles to have initially popped |
|
up such that each Fox would have detected _exactly_ one of them. |
|
|
|
|