ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1112. Cover

Time limit: 0.5 second
Memory limit: 64 MB
You are given N line segments on a line. Every segment is defined with its endpoints Ai and Bi (Ai < Bi, 1 ≤ i ≤ N). Some of the segments probably intersect. Write a program, which removes minimum number of the given segments, so that none of the left segments have common interior point.

Input

The first line of input contains the integer N (1 ≤ N ≤ 99). Each of the following N lines, contains integers Ai and Bi (−999 ≤ Ai < Bi ≤ 999).

Output

On the first line write the integer P, equal to the number of segments, which are left after your program removes the excess segments. The following P lines should contain the coordinates of the left and the right endpoints of the segments which are left. These coordinates must be separated with one space. Coordinates of the left endpoints must be written in their ascending order. If the problem has more the one solution, write only one of them no matter which.

Sample

inputoutput
3
3 6
1 3
2 5
2
1 3
3 6
Problem Source: Bulgarian National Olympiad Day #2