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.*;

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class ProbD {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Segment[] segs = new Segment[n];
            for (int i = 0; i < n; i++){
                int l = in.nextInt();
                int r = in.nextInt();
                segs[i] = new Segment(Math.min(l, r), Math.max(l, r));
            }
            Arrays.sort(segs);

            Segment seg = segs[0];
            ArrayList<Integer> nails = new ArrayList<>();
            nails.add(seg.r);
            int cnt = 1;
            int i = 1;
            while (i < n){
                if (Segment.isIntersect(seg, segs[i])){
                    i++;
                }
                else{
                    seg = segs[i];
                    nails.add(seg.r);
                    i++;
                    cnt++;
                }
            }
            out.println(cnt);
            assert (nails.size() == cnt);
            for (int nail : nails){
                out.print(nail + " ");
            }
        }
    }
    public static class Segment implements Comparable<Segment>{
        public int l, r;
        public Segment(int l, int r){
            this.l = l;
            this.r = r;
        }

        @Override
        public int compareTo(Segment o) {
            if (o.r != this.r){
                return Integer.compare(this.r, o.r);
            }
            return Integer.compare(this.l, o.l);
        }
        public static boolean isIntersect(Segment s1, Segment s2){
            if (s1.l > s2.r || s2.l > s1.r){
                return false;
            }
            return true;
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}