IntermediateRating 1400
Merge Intervals
Merge all overlapping intervals (touching ones too) and print them sorted, one per line.
Input
n, then n lines 'l r'.
Output
Lines.
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
Output appears here