Bessie and her sister Elsie want to travel from the barn to their favorite field, such that they leave at exactly the same time from the barn, and also arrive at exactly the same time at their favorite field. The farm is a collection of fields numbered .., where field contains the barn and field is the favorite field. The farm is built on the side of a hill, with field being higher in elevation than field if . An assortment of paths connect pairs of fields. However, since each path is rather steep, it can only be followed in a downhill direction. For example, a path connecting field with field could be followed in the direction but not the other way, since this would be uphill. It might take Bessie and Elsie different amounts of time to follow a path; for example, Bessie might take units of time, and Elsie . Moreover, Bessie and Elsie only consume time when traveling on paths between fields -- since they are in a hurry, they always travel through a field in essentially zero time, never waiting around anywhere. Please help determine the shortest amount of time Bessie and Elsie must take in order to reach their favorite field at exactly the same moment.
The first input line contains and , separated by a space.
Each of the following lines describes a path using four integers , where and (with ) are the fields connected by the path, is the time required for Bessie to follow the path, and is the time required for Elsie to follow the path.
A single integer, giving the minimum time required for Bessie and Elsie to travel to their favorite field and arrive at the same moment. If this is impossible, or if there is no way for Bessie or Elsie to reach the favorite field at all, output the word IMPOSSIBLE on a single line.
一个整数,表示她们同时出发并同时到达的最短时间。如果无法同时到达,输出 IMPOSSIBLE。
样例
样例输入 #1
3 3
1 3 1 2
1 2 1 2
2 3 1 2
样例输出 #1
2
样例说明
Bessie is twice as fast as Elsie on each path, but if Bessie takes the path and Elsie takes the path they will arrive at the same time.