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
/*
Codeforces
Problem 22D
*/

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Segments {
	
	public static void main(String[] args) throws IOException {
		FastIO in = new FastIO(System.in);
		
		int n = in.nextInt();
		Pair[] segs = new Pair[n];
		
		for (int i = 0; i < n; i++) segs[i] = new Pair(in.nextInt(), in.nextInt());
		Arrays.sort(segs);
		
		List<Integer> nails = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			Pair intersect = new Pair(segs[i].a, segs[i].b);
			for (int j = i; j < n; j++) {
				if (disjoint(segs[j], intersect)) {
					nails.add(intersect.a);
					i = j-1;
					break;
				} else if (j == n-1) {
					intersect.a = Math.max(intersect.a, segs[j].a);
					intersect.b = Math.min(intersect.b, segs[j].b);
					nails.add(intersect.a);
					i = n;
					break;
				} else {
					intersect.a = Math.max(intersect.a, segs[j].a);
					intersect.b = Math.min(intersect.b, segs[j].b);
				}
			}
		}
		
		StringBuilder sb = new StringBuilder();
		sb.append(nails.size()).append('\n');
		for (int i : nails) sb.append(i).append(' ');
		System.out.println(sb.toString().trim());
		
		in.close();
	}
	
	public static boolean disjoint(Pair x, Pair y) {
		if (x.b < y.a || x.a > y.b) return true;
		else return false;
	}
	
	public static class Pair implements Comparable<Pair> {
		int a, b;
		
		public Pair(int a, int b) {
			this.a = Math.min(a, b);
			this.b = Math.max(a, b);
		}
		
		@Override
		public int compareTo(Pair o) {
			return a != o.a ? a - o.a : b - o.b;
		}
		
		@Override
		public String toString() {
			return a + " " + b;
		}
	}
	
	public static class FastIO {
		private InputStream dis;
		private byte[] buffer = new byte[1 << 17];
		private int pointer = 0;
	
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
	
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
	
		public int nextInt() throws IOException {
			int ret = 0;
			byte b;
			
			do {
				b = nextByte();
			} while (b <= ' ');
			
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
	
			return (negative) ? -ret : ret;
		}
	
		public long nextLong() throws IOException {
			long ret = 0;
			byte b;
			
			do {
				b = nextByte();
			} while (b <= ' ');
			
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
			
			return (negative) ? -ret : ret;
		}
	
		public byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
	
		public String next() throws IOException {
			StringBuffer ret = new StringBuffer();
			byte b;
			
			do {
				b = nextByte();
			} while (b <= ' ');
			
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
	
			return ret.toString();
		}
	
		public void close() throws IOException {
			dis.close();
		}
	}
}