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 codeforces.br22;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * User: Kandy
 * Date: 29.06.2010
 * Time: 22:13:07
 */
public class ProblemD {

    private class Interval implements Comparable<Interval> {
        public int l, r;
        public boolean used;

        public Interval(int l, int r) {
            this.l = l;
            this.r = r;
        }


        public int compareTo(Interval o) {
            if (r < o.r)
                return -1;
            if (r > o.r)
                return 1;
            return 0;
        }
    }

    public void solve() {
        boolean oj = true;

        try {
            Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("D.in");
            Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("D.out");
            BufferedReader br = new BufferedReader(reader);
            StreamTokenizer st = new StreamTokenizer(reader);
            PrintWriter out = new PrintWriter(writer);

            MyTokenizer tok = new MyTokenizer(br.readLine());
            int n = (int)tok.getNum();
            List<Interval> list = new ArrayList<Interval>();
            for(int i=0;i<n;i++) {
                tok = new MyTokenizer(br.readLine());
                int l = (int)tok.getNum();
                int r = (int)tok.getNum();
                if (l > r) {
                    int tmp = l;
                    l = r;
                    r = tmp;
                }
                list.add(new Interval(l, r));
            }            

            Collections.sort(list);
            List<Integer> nails = new ArrayList<Integer>();
            for(int i=0;i<list.size();i++)
                if (!list.get(i).used) {
                    int point = list.get(i).r;
                    for(int j=0;j<list.size();j++)
                        if (list.get(j).l <= point && point <= list.get(j).r) {
                            list.get(j).used = true;
                        }
                    nails.add(point);
                }
            out.printf("%d\n", nails.size());
            for(int i=0;i<nails.size();i++) {
                if (i == nails.size() - 1) {
                    out.printf("%d", nails.get(i));
                } else {
                    out.printf("%d ", nails.get(i));
                }
            }

            br.close();
            out.close();
            reader.close();
            writer.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
        finally {
        }
    }


    public static void main(String[] args) {
        ProblemD f = new ProblemD();
        f.solve();
    }

    private class MyTokenizer {
        private String s;
        private int cur;

        public MyTokenizer(String s) {
            this.s = s;
            cur = 0;
        }

        public void skip() {
            while (cur < s.length() && (s.charAt(cur) == ' ' || s.charAt(cur) == '\n')) {
                cur++;
            }
        }

        public double getNum() {
            skip();
            String snum = "";
            while (cur < s.length() && (s.charAt(cur) >= '0' && s.charAt(cur) <= '9' || s.charAt(cur) == '.' || s.charAt(cur) == '-')) {
                snum += s.charAt(cur);
                cur++;
            }
            return Double.valueOf(snum);
        }

        public String getString() {
            skip();
            String s2 = "";
            while (cur < s.length() && (((s.charAt(cur) >= 'a' && s.charAt(cur) <= 'z')) || ((s.charAt(cur) >= 'A' && s.charAt(cur) <= 'Z')))) {
                s2 += s.charAt(cur);
                cur++;
            }
            return s2;
        }

        public char getCurrentChar() throws Exception {
            if (cur < s.length())
                return s.charAt(cur);
            else
                throw new Exception("Current character out of string length");
        }

        public void moveNextChar() {
            if (cur < s.length())
                cur++;
        }

        public boolean isFinished() {
            return cur >= s.length();
        }
    }
}
