eolymp
bolt
Try our new interface for solving problems
Problems

Union of segments

Union of segments

Time limit 1 second
Memory limit 128 MiB

Solving the problem from the quiz in mathematics, Vasya received the answer in the form of union of n segments [l[i], r[i]] on the number line. However, some of these segments may intersect with each other, that Vasya does not like too much.

Your task is to present Vasya's answer as a union of the minimum number of segments.

Input data

The first line contains number n (1n50000). The following n lines contain pairs of integers l[i] and r[i] (|l[i]|, |r[i]| ≤ 50000), each pair is on a new line, numbers in pairs are separated from each other by one or more spaces.

Output data

On the first line print number m - the number of segments in the desired union. In the next m lines print these segments in the same format as in the input. The list of segments must be sorted in ascending order of the left end.

Examples

Input example #1
4
0 2
4 5
1 3
5 6
Output example #1
2
0 3
4 6