516. Schedule
Time limit per test: 1.25
second(s)
Memory limit: 262144
kilobytes
input: standard
output: standard
From the very early days of the Kingdom one of the most honorable duties for its citizen was the duty of the Royal Guardian. The Guardians serve as personal bodyguards for the King. At any moment of time exactly one of the Guardians was assigned to perform this duty.
Recently the King have issued the new labour rules. According to these rules the five day working week (from Monday to Friday) became mandatory for all citizens. Each working day starts at 9:00 in the morning and lasts until 18:00 in the evening. Any duties in nonworking hours are subject for additional reward, however it is not allowed to work more than
T nonworking hours during one calendar week. A week starts on 00:00 on Monday and ends on 24:00 on Sunday.
The Labour Union of Guardians has decided to check the schedule of duties of the Royal Guardians, and you were chosen to help them.
You are given the initial schedule of duties, and a list of updates to this schedule. Find the fraction of time during which the entire schedule was valid according to the labour rules. You are only interested in time interval from
T_{1} to
T_{2}, so you ignore all the duties outside this interval.
Input
The first line of the input file contains three integers
N,
M and
T. Here
N (1 ≤
N ≤ 10
^{5}) is the number of entries in the schedule,
M (0 ≤
M ≤ 10
^{5}) is the number of updates to the schedule, and
T (0 ≤
T ≤ 123) is the number of hours that one is allowed to work during the nonworking hours per week.
The second line contains two dates —
T_{1} and
T_{2} (It is guaranteed that
T_{1} comes earlier than
T_{2}).
The next
N lines describes the initial schedule of the Guardians. Each line consists of a date
D_{i} and the name of the Guardian that starts his duty at time
D_{i} (1 ≤
i ≤
N, it is guaranteed that
D_{i}s are in ascending order, and
D_{1} comes no later than
T_{1}). (The name is a casesensitive sequence of English characters.) After starting his duty at time
D_{i} the Guardian serves until the next Guardian comes to replace him.
Each of the following
M lines describes the schedule of updates. Each update is described by
A_{i} — the date when this update become active,
B_{i} and
E_{i} (the time slot of the update), and the Guarding name (in the same format as above). When this update becomes active, the schedule is modified in the following manner: this guardian will now serve the duties between
B_{i} and
E_{i}, the schedule outside this time slot is not affected (see the note below the example for more explanations). It is guaranteed that
A_{i} comes no later than
B_{i}, and
B_{i} earlier than
E_{i}. All
A_{i}s are in nondescending order. When several updates happen at the same time, you should apply them in the order they're given in the input file.
All
T_{i},
D_{i},
A_{i},
B_{i} and
E_{i} in the input file are dates in format YYYYMMDD hh:mm. All dates are between 20090101 00:00 and 20091231 23:59, inclusive.
Output
Output just one number — the fraction of time from
T_{1} to
T_{2} during which the schedule was valid according to the labour rules. Your answer will be accepted when it's within 10
^{6} absolute or relative error of the correct one.
Example(s)
sample input

sample output

2 1 2 20091207 09:00 20091207 22:00 20091207 08:00 Vasya 20091207 14:00 Vanya 20091207 15:00 20091207 16:00 20091207 20:00 Vasya

0.53846153846153844

Note
Here's what happens in the example case. We're only interested in a part of a day, from 9 in the morning to 22 in the evening. Initially, Vasya is scheduled to perform the duties from 9 in the morning to 14 in the afternoon, and Vanya is scheduled to perform the duties from 14 in the afternoon to 22 in the evening. This means Vasya works only during the working hours, and Vanya gets all the hard work of 4 nonworking hours, which is more than the maximum of 2 allowed. Thus this schedule is invalid according to the labour rules.
However, at 15 in the afternoon the schedule is updated. Now, Vasya is performing the duties from 9 to 14 and from 16 to 20, and Vanya is performing the duties from 14 to 16 and from 20 to 22. This means 2 nonworking hours for each of the Guardians, which is allowed under the labour rules.
So the schedule was invalid from 9 in the morning to 15 in the afternoon, and valid from 15 in the afternoon to 22 in the evening, which corresponds to the fraction of 7/13.