#D5039. Rainy Bus Stops
Rainy Bus Stops
Rainy Bus Stops
problem
AOR Ika is at the th bus stop at time and wants to go from there to the th bus stop. The number of bus stops and routes (*) connecting different bus stops are given. The bus stops are numbered , respectively. Each route consists of values: origin , destination , departure time , and travel time . You can catch the bus if you are at the departure at the time and arrive at the destination at the time . While not on the bus, AOR Ika gets wet in the rain. When heading to the th bus stop through the route that minimizes the time of getting wet in the rain, output the total time of getting wet in the rain from the time to the arrival at the th bus stop.
(*) In graph theory terms, a path is a sequence of vertices and edges, but please note that it is used here to mean edges.
input
Input is given from standard input in the following format.
output
Print the minimum amount of time you get wet in one line. Also, output a line break at the end.
Example
Input
2 2 1 2 1 2 10 100 1 2 5 500
Output
5
inputFormat
outputFormat
output the total time of getting wet in the rain from the time to the arrival at the th bus stop.
(*) In graph theory terms, a path is a sequence of vertices and edges, but please note that it is used here to mean edges.
input
Input is given from standard input in the following format.
output
Print the minimum amount of time you get wet in one line. Also, output a line break at the end.
Example
Input
2 2 1 2 1 2 10 100 1 2 5 500
Output
5
样例
2 2 1 2
1 2 10 100
1 2 5 500
5