
Joey is going to take a vacation in Mexico. He wants to go from Toronto Pearson International Airport YYZ
to Cancun International Airport CUN
. During the way, he may make multiple stops.
During his trip, he will pass through YYZ
labelled CUN
labelled YYZ
on day
In total, there are
In Mexico, there is a celebration of the fire god every hour of the day. Given that he travels optimally, what is the time of the earliest show that Joey can watch?
Input Specification
The first line will contain
The next
It is guaranteed that it is always possible to fly to Mexico.
Output Specification
Print a single line: Day D Hour H
, indicating the time of the earliest show that Joey can watch.
Sample Input 1
2 1
1 1 1
Sample Output 1
Day 0 Hour 3
Sample Explanation 1
Joey arrives at airport 2:00
, and gets off at 2:20
.
Sample Input 2
3 3
1 2 10
1 1 48
2 12 1
Sample Output 2
Day 1 Hour 14
Sample Explanation 2
Joey should not take the plane that takes
Joey should arrive at airport
He gets on the airplane to depart airport 13:20
and visits the show on Day
Comments