#P431. 【例75.2】 区间合并
【例75.2】 区间合并
Description
Given closed intervals [, ], where .
Any two adjacent or overlapping closed intervals can be merged into one closed interval. For example, [, ] and [, ] can be merged into [, ], [, ] and [, ] can be merged into [, ], but [, ] and [, ] cannot be merged.
Our task is to determine if these intervals can be merged into a single closed interval. If possible, output this closed interval; otherwise, output "".
Input Format
The first line contains an integer , , representing the number of intervals. The next lines each contain two integers and , separated by a space, representing the interval [, ] (where ).
Output Format
Output one line. If these intervals can be merged into a single closed interval, output the left and right boundaries of this closed interval, separated by a space; otherwise, output "".
Sample
5
5 6
1 5
10 10
6 9
8 101 10