Merge Intervals
Merge all overlapping intervals (touching ones like [1,3] and [3,5] also merge) and print the result sorted by start.
Input
, then lines start end with start ≤ end.
Output
The merged intervals, one per line.
Constraints
, start ≤ end ≤
Sample 1
Input
4 1 3 2 6 8 10 15 18
Output
1 6 8 10 15 18
Sample 2
Input
2 1 4 4 5
Output
1 5