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
//package com.cf.r22;//package com.cf.r664;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.OptionalInt;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class D {

	private FastScanner in;
	private PrintWriter out;

	public static void main(String[] args) {
		new D().run();
	}

	private static class Segment implements Comparable<Segment> {
		int from;
		int to;

		public Segment(int from, int to) {
			this.from = Math.min(from, to);
			this.to = Math.max(from, to);
		}

		@Override
		public int compareTo(Segment o) {
			return 2 * Integer.compare(to, o.to) + Integer.compare(from, o.from);
		}
	}

	private void run() {
		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		int n = in.nextInt();

		List<Segment> segmentos = IntStream.range(0, n).mapToObj(i -> new Segment(in.nextInt(), in.nextInt())).collect(
				Collectors.toList());

		Collections.sort(segmentos);

		List<Integer> stacked = new ArrayList<>();
		int lastStacked = -20000;

		for (Segment segmento : segmentos) {
			if (lastStacked < segmento.from) {
				lastStacked = segmento.to;
				stacked.add(segmento.to);
			}
		}

		out.println(stacked.size());
		out.println(stacked.stream().map(String::valueOf).collect(Collectors.joining(" ")));

		out.close();
	}

	static class FastScanner {

		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}
