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 static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;

public class D implements Runnable
{
	String file = "input";
	
	void init() throws IOException
	{
		//input = new BufferedReader(new FileReader(file + ".in"));
		input = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new BufferedOutputStream(System.out));
	}
	int[] x, y;
	void solve() throws IOException
	{
		int n = nextInt();
		x = new int[n];
		y = new int[n];
		for(int i = 0; i < n; i++)
		{
			x[i] = nextInt();
			y[i] = nextInt();
			if(x[i] > y[i])
			{
				int t = x[i];
				x[i] = y[i];
				y[i] = t;
			}
		}	
		Integer[] o = new Integer[n];
		for(int i = 0; i < n; i++) o[i] = i;
		Arrays.sort(o, new Comparator<Integer>(){
			public int compare(Integer i, Integer j)
			{
				return y[i] - y[j];
			}
		});
		
		boolean[] done = new boolean[n];
		List<Integer> res = new ArrayList<Integer>();
		for(int i = 0; i < n; i++)
			if(!done[i])
			{
				res.add(y[o[i]]);
				for(int j = i; j < n; j++)
					if(x[o[j]] <= y[o[i]])
						done[j] = true;
			}
		out.println(res.size());
		out.print(res.get(0));
		for(int i = 1; i < res.size(); i++) out.print(" " + res.get(i));
		out.println();
		
	}
	
	String next() throws IOException
	{
		while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(input.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	
	void print(Object... o)
	{
		System.out.println(deepToString(o));
	}
	
	void gcj(Object o)
	{
		String s = String.valueOf(o);
		out.println("Case #" + test + ": " + s);
		System.out.println("Case #" + test + ": " + s);
	}
	
	BufferedReader input;
	PrintWriter out;
	StringTokenizer st;
	int test;
	
	public static void main(String[] args) throws IOException
	{
		new Thread(null, new D(), "", 1 << 20).start();
	}
	
	public void run()
	{
		try
		{
			init();
			solve();
			out.close();		
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.exit(1);
		}
	}
}