Given N line segments. Find the length of the common part of all these segments.
Input The number N is entered first (1<=N<=100). Next, N pairs of numbers are entered, specifying the coordinates of the left and right ends of each segment. All coordinates are numbers from the range from 0 to 30000. The left end of the segment always has a coordinate strictly less than the right one.
Output Print the length of the common part of these segments. If all these segments don't have a common part, print 0.
Examples
# |
Input |
Output |
Explanation |
1 |
3
1 10
3 15
26
|
3 |
the common part of these segments is the segment from 3 to 6. |
2 |
3
1 10
2 20
11 20
|
0 |
these segments have no common part |