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.*;
import java.math.BigInteger;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }

    private static class TaskB {

        static final long max = 10000000000000000L;
        static final double eps = 0.000001;


        void solve(InputReader in, PrintWriter out) throws IOException {

            int n = in.nextInt();
            Pair[] pair = new Pair[n];
            int C[] = new int[20001];
            int F[] = new int[20001];
            int was[] = new int[20001];

            int right = Integer.MIN_VALUE;
            int left = Integer.MAX_VALUE;

            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                int b = in.nextInt();

                a += 10000;
                b += 10000;

                if (a < b)
                    pair[i] = new Pair(a, b);
                else pair[i] = new Pair(b, a);

                for (int j = pair[i].a; j <= pair[i].b; j++) {
                    C[j]++;
                    was[j] = 1;
                }

                if (pair[i].b > right)
                    right = pair[i].b;

                if (pair[i].a < left)
                    left = pair[i].a;
            }

            Arrays.sort(pair, new Comparator<Pair>() {
                @Override
                public int compare(Pair o1, Pair o2) {
                     return o1.b - o2.b;
                }
            });

            for (int i = 0; i < n; i++) {

                int x = -1;
                int max = Integer.MIN_VALUE;

                for (int j = pair[i].a; j <= pair[i].b; j++) {

                    if (F[j] == 1) {
                        x = -1;
                        break;
                    }
                    if (C[j] > max) {
                        max = C[j];
                        x = j;
                    }
                }

                if (x > -1) {
                    F[x] = 1;
                }

                for (int j = pair[i].a; j <= pair[i].b; j++)
                    C[j]--;

            }

            //for (int i = left; i <= right; i++)
                //if (was[i] == 0) F[i] = 1;

            Queue<Integer> q = new LinkedList<>();

            for (int i = left; i <= right; i++)
                if (F[i] == 1) q.add(i);

            out.println(q.size());
            if (!q.isEmpty()) out.print(q.poll() - 10000);
            while (!q.isEmpty()) {
                out.print(" " + (q.poll() - 10000));
            }


        }

        class Pair {
            int a, b;

            Pair(int a, int b) {
                this.a = a;
                this.b = b;
            }
        }

        double segment(double x1, double y1, double x2, double y2) {
            return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }

        long gcd(long a, long b) {
            if (b == 0) return a;
            return gcd(b, a % b);
        }

        long lcm(long a, long b) {
            return (a * b) / gcd(a, b);
        }

    }

    private static class InputReader {
        StringTokenizer st;
        BufferedReader br;

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

        public InputReader(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

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

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

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

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

        public boolean ready() {
            try {
                return br.ready();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}