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 static java.util.Arrays.sort;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Segments implements Runnable
{
  public static void main(String[] args) throws Exception
  {
    new Segments().run();
  }

  private void solve() throws Exception
  {
    int n = nextInt();
    Event[] e = new Event[2 * n];
    for (int i = 0, j = 0; i < n; i++)
    {
      int a = nextInt(), b = nextInt();
      if (a > b)
      {
        int tmp = a;
        a = b;
        b = tmp;
      }
      e[j] = new Event(a, 0, i);
      j++;
      e[j] = new Event(b, 1, i);
      j++;
    }

    sort(e);

    boolean active[] = new boolean[n], touch[] = new boolean[n];
    ArrayList<Integer> retl = new ArrayList<Integer>();
    for (int i = 0; i < e.length; i++)
    {
      Event cur = e[i];
      // begin
      if (cur.type == 0)
        active[cur.index] = true;
      else
      // end
      {
        if (!touch[cur.index])
        {
          for (int j = 0; j < n; j++)
          {
            if (active[j])
              touch[j] = true;
          }
          retl.add(cur.x);
        }
        active[cur.index] = false;
      }
    }

    out.println(retl.size());
    for (int i = 0, len = retl.size(); i < len; i++)
    {
      out.print(retl.get(i));
      if (i != len - 1)
        out.print(" ");
    }
    out.println();
  }

  class Event implements Comparable<Event>
  {
    // type : 0 - begin, 1 - end
    int x, type, index;

    public Event(int x, int type, int index)
    {
      super();
      this.x = x;
      this.type = type;
      this.index = index;
    }

    public int compareTo(Event other)
    {
      if (x != other.x)
        return x - other.x;
      if (type != other.type)
        return type - other.type;
      return index - other.index;
    }

  }

  // -------------- Input/Output routines below ---------------//
  private BufferedReader in;
  PrintWriter out;
  StringTokenizer tokenizer;

  public void run()
  {
    // String problem = this.getClass().getName();
    try
    {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new BufferedOutputStream(System.out));
      solve();
      out.flush();
      in.close();
      out.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      // System.exit(1);
    }
  }

  String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(in.readLine());
    }
    return tokenizer.nextToken();
  }

  int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

}