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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt();
            int[] l = new int[n], r = new int[n];
            boolean[] finished = new boolean[n];
            ArrayList<Integer> res = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt(), b = sc.nextInt();
                l[i] = Math.min(a, b);
                r[i] = Math.max(a, b);
            }
            while (true) {
                boolean finishedAll = true;
                for (int i = 0; i < n; i++)
                    finishedAll &= finished[i];
                if (finishedAll) break;
                int bestIdx = -1;
                for (int i = 0; i < n; i++)
                    if (!finished[i] && (bestIdx == -1 || r[bestIdx] > r[i]))
                        bestIdx = i;
                res.add(r[bestIdx]);
                for (int i = 0; i < n; i++)
                    if (l[i] <= r[bestIdx] && r[i] >= r[bestIdx])
                        finished[i] = true;
            }

            out.println(res.size());
            for (int i = 0; i < res.size(); i++) {
                if (i > 0) out.print(" ");
                out.print(res.get(i));
            }
            out.println();
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}

