Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
File size: 3,049 Bytes
761e24d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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.

At Corpro Corp, each workday is 80,000,000 milliseconds long, and the company
uses the phrase "time **t**" to refer to the moment in time **t** milliseconds
after the start of the workday. All employees arrive at time 0, and leave at
time 80,000,000.

On a certain day, James gets invited to **J** optional meetings. The **i**th
of these meetings starts at time **Ai** and ends at time **Bi**. Similarly,
Wilson gets invited to **W** optional meetings, with the **i**th one starting
at time **Ci** and ending at time **Di**. All **J**+**W** meetings might
arbitrarily overlap with one another.

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.

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
**L** milliseconds, and so the two friends will meet up for lunch if there's a
consecutive interval of at least **L** milliseconds within their work hours
during which neither of them is taking part in any meetings.

Less surprisingly, James and Wilson hate attending meetings. If James accepts
**x** of his **J** invitations, and Wilson accepts **y** of his **W**
invitations, then the combined inconvenience they experience is max(**x**,
**y**). 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.

### Input

Input begins with an integer **T**, the number of days James and Wilson go to
work. For each day, there is first a line containing the space-separated
integers **J**, **W**, and **L**.

Then, **J** lines follow, the **i**th of which contains the space-separated
integers **Ai** and **Bi**.

Then, **W** lines follow, the **i**th of which contains the space-separated
integers **Ci** and **Di**.

### Output

For the **i**th day, print a line containing "Case #**i**: " followed by the
minimum combined inconvenience James and Wilson must experience, or
"Lunchtime" if they cannot avoid having lunch together.

### Constraints

1 ≤ **T** ≤ 20  
0 ≤ **J**, **W** ≤ 3000  
1 ≤ **L** ≤ 100,000,000  
0 ≤ **Ai** < **Bi** ≤ 80,000,000  
0 ≤ **Ci** < **Di** ≤ 80,000,000  

### Explanation of Sample

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.