#include <bits/stdc++.h>
using namespace std;
struct segment {
  int from, to;
  bool nailed;
  segment(int f, int t) : from(min(f, t)), to(max(f, t)), nailed(false) {}
  bool contains(int coord) const {
    return coord >= min(from, to) && coord <= max(from, to);
  }
  bool operator<(const segment &other) const { return to < other.to; }
};
struct state {
  enum type { OPEN, CLOSE } t;
  int coord, seg;
  state(int coord, int seg, type t) : t(t), coord(coord), seg(seg) {}
  bool operator<(const state &other) const {
    if (coord < other.coord)
      return true;
    else if (coord > other.coord)
      return false;
    if (t == OPEN && other.t == CLOSE) return true;
    return false;
  }
};
vector<segment> read_data(void) {
  int n;
  cin >> n;
  vector<segment> result;
  result.reserve(n);
  for (int i = 0; i < n; ++i) {
    int from, to;
    cin >> from >> to;
    result.push_back(segment(from, to));
  }
  return result;
}
vector<int> solve(vector<segment> segments) {
  vector<state> states;
  for (int i = 0; i < segments.size(); ++i) {
    states.push_back(state(segments[i].from, i, state::OPEN));
    states.push_back(state(segments[i].to, i, state::CLOSE));
  }
  sort(states.begin(), states.end());
  vector<int> result;
  list<int> segs;
  for (int i = 0; i < states.size(); ++i) {
    if (states[i].t == state::OPEN) {
      if (segments[states[i].seg].nailed == false)
        segs.push_back(states[i].seg);
    } else if (!segments[states[i].seg].nailed) {
      result.push_back(states[i].coord);
      for (list<int>::iterator it = segs.begin(); it != segs.end(); ++it)
        segments[*it].nailed = true;
      segs.resize(0);
    }
  }
  return result;
}
int main(void) {
  vector<int> ans = solve(read_data());
  cout << ans.size() << endl;
  copy(ans.begin(), ans.end(), ostream_iterator<int>(cout, " "));
  cout << endl;
  return 0;
}
