#include <bits/stdc++.h>
using namespace std;
enum { BEGIN = 0, END = 1 };
struct event_t {
  event_t(int x_, int type_, int index_) : x(x_), type(type_), index(index_) {}
  bool operator<(const event_t& e) const {
    if (x != e.x)
      return x < e.x;
    else if (type != e.type)
      return type < e.type;
    else
      return index < e.index;
  }
  int x, type, index;
};
int main() {
  int n;
  scanf("%d", &n);
  vector<event_t> events;
  for (int i = 0; i < n; ++i) {
    int begin, end;
    scanf("%d %d", &begin, &end);
    if (begin > end) swap(begin, end);
    events.push_back(event_t(begin, BEGIN, i));
    events.push_back(event_t(end, END, i));
  }
  sort(events.begin(), events.end());
  vector<int> nails;
  vector<bool> active(n, false), touched(n, false);
  for (int i = 0; i < (int)events.size(); ++i) {
    const event_t& e = events[i];
    if (e.type == BEGIN)
      active[e.index] = true;
    else {
      if (!touched[e.index]) {
        for (int k = 0; k < n; ++k)
          if (active[k]) touched[k] = true;
        nails.push_back(events[i].x);
      }
      active[e.index] = false;
    }
  }
  printf("%d\n", (int)nails.size());
  if (!nails.empty()) {
    printf("%d", nails[0]);
    for (int k = 1; k < (int)nails.size(); ++k) printf(" %d", nails[k]);
  }
  printf("\n");
  return 0;
}
