Bus Trip
There are N towns, and M one-way direct bus routes (no intermediate stops) between them. The towns are numbered from 1 to N. A traveler who is located in the town 1 at time 0 needs to arrive in the town P. He will be picked from the bus station at town P exactly at time T. If he arrives earlier he will have to wait.
For each bus route i, we know the source and destination towns s_i and t_i, of course. We also know the departure and arrival times, but only approximately: we know that the bus departs from s_i within the range [a_i, b_i] and arrives at t_iwithin the range [c_i, d_i] (endpoints included in both cases).
The traveler does not like waiting, and therefore is looking for a travel plan which minimizes the maximal possible waiting time while still guaranteeing that he'll not miss connecting buses (that is, every time he changes buses, the latest possible arrival of the incoming bus must not be later than the earliest possible departure time of the outgoing bus).
When counting waiting time we have to assume the earliest possible arrival time and the latest possible departure time.
Write a program to help the traveler to find a suitable plan.
Input
The first line contains the integer numbers N (1 ≤ N ≤ 50000), M (1 ≤ M ≤ 100000), P (1 ≤ P ≤ N), and T (0 ≤ T ≤ 1000000000).
The following M lines describe the bus routes. Each line contains the integer numbers s_i, t_i, a_i, b_i, c_i, d_i, where s_i and t_i are the source and destination towns of the bus route i, and a_i, b_i, c_i, d_i describe the departure and arrival times as explained above (1 ≤ s_i ≤ N, 1 ≤ t_i ≤ N, 0 ≤ a_i ≤ b_i < c_i ≤ d_i ≤ 1000000000).
Output
The only line of the output file should contain the maximal possible total waiting time for the most suitable possible travel plan. If it is not possible to guarantee arrival in town P by time T, the line should contain –1.