|
<p> |
|
Phineas is the proud owner of an enormous new fish tank! Looking at the fish tank from the side, it can be represented as an infinite 2D plane. |
|
Phineas has installed <strong>N</strong> vertical dividers into the tank, the <em>i</em>th of which is a line segment connecting points |
|
(<strong>X<sub>i</sub></strong>, <strong>A<sub>i</sub></strong>) and (<strong>X<sub>i</sub></strong>, <strong>B<sub>i</sub></strong>). |
|
No two dividers overlap at any point (including at their endpoints). |
|
</p> |
|
|
|
<p> |
|
Unfortunately, Phineas's fish tank is lacking in fish, but he'll soon rectify that! He's going to place one or more fish into the tank, with each one initially occupying any point of his choice |
|
(each coordinate may be non-integral and arbitrarily small or large). No fish's location may overlap with any of the dividers (including their endpoints), but multiple fish may be placed at the same coordinates. |
|
</p> |
|
|
|
<p> |
|
After the fish have been placed, each one may swim left and right freely (continuously decreasing or increasing its x-coordinate), as long as it never touches a divider (including its endpoints). Fish do not block one another from swimming, so multiple fish are able to occupy the same coordinates. However, no fish is able to change its y-coordinate. |
|
</p> |
|
|
|
<p> |
|
At any given moment, each fish feels that its personal space is violated if any other fish is currently at the same x-coordinate as it |
|
(either at its current y-coordinate, or arbitrarily far above or below it). As such, if two fish ever occupy the same x-coordinate as one another, they both become unhappy. |
|
</p> |
|
|
|
<p> |
|
Phineas suspects that someone's planning on stealing one of his dividers soon after he places fish into the tank! |
|
</p> |
|
|
|
<p> |
|
And he wants to ensure that none of his fish have any chance of becoming unhappy! |
|
</p> |
|
|
|
<p> |
|
But he still wants to have as many fish as possible! |
|
</p> |
|
|
|
<p> |
|
As such, he'd like to determine the maximum number of fish which he can place into the tank such that, no matter which single one of the <strong>N</strong> dividers is subsequently removed, |
|
and no matter how the fish then decide to swim around, none of the fish can ever become unhappy. |
|
</p> |
|
|
|
|
|
<h3>Input</h3> |
|
|
|
<p> |
|
Input begins with an integer <strong>T</strong>, the number of fish tanks. |
|
For each fish tank, there is first a line containing the single integer <strong>N</strong>. |
|
Then, <strong>N</strong> lines follow, the <em>i</em>th of which contains the 3 space-separated integers |
|
<strong>X<sub>i</sub></strong>, <strong>A<sub>i</sub></strong>, and <strong>B<sub>i</sub></strong>. |
|
</p> |
|
|
|
|
|
<h3>Output</h3> |
|
|
|
<p> |
|
For the <em>i</em>th fish tank, output a line containing "Case #<em>i</em>: " followed by the maximum number of fish which Phineas can place into the tank with no risk of unhappiness. |
|
</p> |
|
|
|
|
|
<h3>Constraints</h3> |
|
|
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 90<br /> |
|
1 ≤ <strong>N</strong> ≤ 500,000 <br /> |
|
0 ≤ <strong>X<sub>i</sub></strong> ≤ 1,000,000,000 <br /> |
|
0 ≤ <strong>A<sub>i</sub></strong> < <strong>B<sub>i</sub></strong> ≤ 1,000,000,000 <br /> |
|
</p> |
|
|
|
|
|
<h3>Explanation of Sample</h3> |
|
|
|
<p> |
|
In the first case, Phineas could, for example, place a fish at coordinates (5, 5). If he placed another fish anywhere else in the tank (for example at coordinates (-1, 2)), |
|
then if the single divider were removed, both fish would be able to swim freely and might come to occupy the same x-coordinate as one another. |
|
</p> |
|
|
|
<p> |
|
In the second case, Phineas can place one fish at coordinates (-5, 5) and another at coordinates (15, 5). |
|
</p> |
|
|
|
<p> |
|
In the third case, no matter where Phineas might place two fish in the tank, at least one choice of removed divider would result in them potentially becoming unhappy. |
|
</p> |
|
|
|
|
|
|