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.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Stack;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Erasyl Abenov
 * 
 * 
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
            try (PrintWriter out = new PrintWriter(outputStream)) {
                TaskB solver = new TaskB();
                solver.solve(1, in, out);
            }
    }
}
class TaskB {
    class Point implements Comparable<Point>{
        int start;
        int end;
        public Point(int start, int end){
            this.start = start;
            this.end = end;
        }
        @Override
        public int compareTo(Point o){
            if(o.start != start) return start - o.start;
            return end - o.end;
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException{
        int n = in.nextInt();
        Point p[] = new Point[n];
        for(int i = 0; i < n; ++i){
            int s = in.nextInt();
            int f = in.nextInt();
            if(s > f){
                int tmp = f;
                f = s;
                s = tmp;
            }
            p[i] = new Point(s, f);
        }
        Arrays.sort(p);
        Stack<Integer> st = new Stack();
        st.add(p[0].end);
        for(int i = 0; i < n; ++i){
            if(p[i].end < st.lastElement()){
                st.pop();
                st.add(p[i].end);
            }
            else if(p[i].start > st.lastElement())
                st.add(p[i].end);
        }
        out.println(st.size());
        for(int coord : st){
            out.print(coord);
            out.print(" ");
        }
    }
}
class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }
    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }
      
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public BigInteger nextBigInteger(){
        return new BigInteger(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}