#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
using namespace std;
const int N = 1e6 + 5, M = 1e3 + 5, eps = 1e9 + 5;
const long long inf = 1e19 + 5;
struct line {
  int l, r;
} ar[M];
int n, cnt;
vector<int> p;
void print() {
  printf("%d\n", p.size());
  for (int i = 0; i < p.size(); i++)
    printf("%d%c", p[i], " \n"[i + 1 == p.size()]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    ar[i] = {x, y};
  }
  sort(ar, ar + n, [](line a, line b) { return a.l < b.l; });
  int first_r = ar[0].r;
  for (int i = 1; i < n; i++) {
    if (ar[i].l <= first_r)
      first_r = min(ar[i].r, first_r);
    else {
      p.push_back(first_r);
      first_r = ar[i].r;
    }
  }
  p.push_back(first_r);
  print();
  return 0;
}
