Buses
Between some villages of Vasyuki district there are buses routes. As the passenger traffic is not very large, the buses run only a few times a day.
Maria Ivanovna wants to get from the village to the village as soon as possible (it is assumed that at time she is in the village ).
Input
First given the total number of villages , and , then the number of bus lines . Then given the description of bus trips. Each route is given by the number of the starting village, time of departure, the destination village and the arrival time (all times are integers from to ). If at time the passenger arrives in the village, he can leave it at any time, starting from .
Output
Print the minimum time when Maria Ivanovna can reach the village . If she fails with these bus trips to get from to , output .