You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is considered to be nailed too. What is the smallest number of nails needed to nail all the segments down?

Input

The first line of the input contains single integer number n (1 ≤ n ≤ 1000) — amount of segments. Following n lines contain descriptions of the segments. Each description is a pair of integer numbers — endpoints coordinates. All the coordinates don't exceed 10000 by absolute value. Segments can degenarate to points.

Output

The first line should contain one integer number — the smallest number of nails needed to nail all the segments down. The second line should contain coordinates of driven nails separated by space in any order. If the answer is not unique, output any.

Examples

Input

2
0 2
2 5


Output

1
2 

Input

5
0 3
4 2
4 8
8 10
7 7


Output

3
7 10 3

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

public class Four {
	InputStreamReader inp = new InputStreamReader(System.in);
	BufferedReader in = new BufferedReader(inp);
	boolean test = false;

	String[] inData = { "5",
"0 3",
"4 2",
"4 8",
"8 10",
"7 7" };

	static int id = -1;

	public String readLine() throws IOException {
		id++;
		if (test)
			return inData[id];
		else
			return in.readLine();
	}

	class Segment{
		int start;
		int end;
		public Segment(int start, int end) {
			if(start < end){
				this.start = start;
				this.end = end;
					
			} else {
				this.start = end;
				this.end = start;
				
			}
		}
	}
	
	public void solve() throws Exception {
		int lines = Integer.valueOf(readLine());
		
		List<Segment> segs = new ArrayList<Segment>();  
		
		for (int i = 0; i < lines; i++) {
			String[] readLine = readLine().split(" ");
			
			segs.add(new Segment(Integer.valueOf(readLine[0]),Integer.valueOf(readLine[1]))); 
		}

		List<Integer> rounds = new ArrayList<Integer>();
		
		while(segs.size() > 0){
			Collections.sort(segs, new Comparator<Segment>() {

				@Override
				public int compare(Segment o1, Segment o2) {
					if(o1.end < o2.end)
						return -1;
					return 1;
				}
			});
			//insert nail at end
			Segment segment = segs.get(0);
			int end = segment.end;
			rounds.add(end);
			
			for (Iterator iterator = segs.iterator(); iterator.hasNext();) {
				Segment seg = (Segment) iterator.next();
				if(seg.start <= end){
					iterator.remove();
				}
				
			}
		}
		
		System.out.println(rounds.size());
		
		StringBuilder b = new StringBuilder();
		for (Integer integer : rounds) {
			b.append(integer + " ");
		}
		
		System.out.println(b.toString().substring(0, b.length()-1));
	}
	
	private int maxConns(int islandOne) {
		int sum = 0;
		for (int i = 1; i <= islandOne; i++) {
			sum += i;
		}
		return sum;
	}

	public static void main(String[] args) throws Exception {
//		long currentTimeMillis = System.currentTimeMillis();
		new Four().solve();
//		System.out.println((System.currentTimeMillis() - currentTimeMillis));
	}
}
