European Space Agency has
After many years of observation, they want to analyze data. The telescopes logged all observations, but unfortunately they forgot to write down the year the observations took place! Each telescope entry consists of the start date, end date and number of each type of event observed. Given all observations on all planets, calculate the duration of each type of event. Note that the telescopes are super precise and they start working exactly when the event starts and end when an event ends, not necessarily the same one.
Note: For this task, each year has exactly
Input Specification
First line contains integers
"
Where
Output Specification
One line containing -1
.
Sample Input 1
1 1
26 02 03 03 1
Sample Output 1
5
Explanation for Sample Output 1
The telescope observed one type 1 event between 26 February and 3 March. The only possible explanation is that type 1 events last 5 days.
Sample Input 2
1 1
26 02 03 03 2
Sample Output 2
185
Sample Input 3
3 3
22 03 01 10 9 10 10
05 05 16 12 1 7 10
20 06 15 01 4 9 10
Sample Output 3
102
204
125
Comments