|
<p> |
|
James and Wilson are the best of buddies. And, conveniently enough, they both work at Corpro Corp! Every day, they have the opportunity to eat lunch together, while talking about how well their favourite sports teams are doing and how strict their managers are. However, their work obligations can often get in the way of that. |
|
</p> |
|
|
|
<p> |
|
At Corpro Corp, each workday is 80,000,000 milliseconds long, and the company uses the phrase "time <strong>t</strong>" |
|
to refer to the moment in time <strong>t</strong> milliseconds after the start of the workday. |
|
All employees arrive at time 0, and leave at time 80,000,000. |
|
</p> |
|
|
|
<p> |
|
On a certain day, James gets invited to <strong>J</strong> optional meetings. The <strong>i</strong>th of these meetings |
|
starts at time <strong>A<sub>i</sub></strong> and ends at time <strong>B<sub>i</sub></strong>. |
|
Similarly, Wilson gets invited to <strong>W</strong> optional meetings, with the <strong>i</strong>th one |
|
starting at time <strong>C<sub>i</sub></strong> and ending at time <strong>D<sub>i</sub></strong>. |
|
All <strong>J</strong>+<strong>W</strong> meetings might arbitrarily overlap with one another. |
|
</p> |
|
|
|
<p> |
|
Both James and Wilson may choose to accept any subset of their invitations, possibly none of them or all of them. |
|
The meetings are all conducted virtually, making it possible to attend multiple meetings at the same time — |
|
as such, two invitations may be accepted even if their time ranges overlap. |
|
</p> |
|
|
|
<p> |
|
As it turns out, James and Wilson actually hate having lunch together, but they feel obligated to do so if they're able to. |
|
Eating lunch takes exactly <strong>L</strong> milliseconds, and so the two friends will meet up for lunch if there's a |
|
consecutive interval of at least <strong>L</strong> milliseconds within their work hours during which neither of them |
|
is taking part in any meetings. |
|
</p> |
|
|
|
<p> |
|
Less surprisingly, James and Wilson hate attending meetings. If James accepts <strong>x</strong> of his |
|
<strong>J</strong> invitations, and Wilson accepts <strong>y</strong> of his <strong>W</strong> invitations, |
|
then the combined inconvenience they experience is max(<strong>x</strong>, <strong>y</strong>). |
|
Determine whether or not it's possible for them to avoid having to eat lunch together — |
|
and, if so, determine the minimum combined inconvenience they must incur to do so. |
|
</p> |
|
|
|
|
|
<h3>Input</h3> |
|
<p> |
|
Input begins with an integer <strong>T</strong>, the number of days James and Wilson go to work. |
|
For each day, there is first a line containing the space-separated integers |
|
<strong>J</strong>, <strong>W</strong>, and <strong>L</strong>. |
|
</p> |
|
|
|
<p> |
|
Then, <strong>J</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers |
|
<strong>A<sub>i</sub></strong> and <strong>B<sub>i</sub></strong>. |
|
</p> |
|
|
|
<p> |
|
Then, <strong>W</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers |
|
<strong>C<sub>i</sub></strong> and <strong>D<sub>i</sub></strong>. |
|
</p> |
|
|
|
|
|
<h3>Output</h3> |
|
<p> |
|
For the <strong>i</strong>th day, print a line containing "Case #<strong>i</strong>: " followed by |
|
the minimum combined inconvenience James and Wilson must experience, or "Lunchtime" if they cannot |
|
avoid having lunch together. |
|
</p> |
|
|
|
|
|
<h3>Constraints</h3> |
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 20 <br /> |
|
0 ≤ <strong>J</strong>, <strong>W</strong> ≤ 3000 <br /> |
|
1 ≤ <strong>L</strong> ≤ 100,000,000 <br /> |
|
0 ≤ <strong>A<sub>i</sub></strong> < <strong>B<sub>i</sub></strong> ≤ 80,000,000 <br /> |
|
0 ≤ <strong>C<sub>i</sub></strong> < <strong>D<sub>i</sub></strong> ≤ 80,000,000 <br /> |
|
</p> |
|
|
|
<h3>Explanation of Sample</h3> |
|
<p> |
|
In the first case, James can attend the meeting from time 40,000,000 to 70,000,000, and Wilson can attend |
|
the meeting from time 10,000,000 to time 21,000,000. They each attend one meeting, so the combined |
|
inconvenience is 1. |
|
</p> |
|
|
|
|
|
|