#include <bits/stdc++.h>
using namespace std;
int n;
int s[33][33] = {};
int mark_l[10010] = {}, mark_r[10010] = {};
int path[10010];
struct node {
  int l, r;
  bool operator<(const node &x) const {
    return l < x.l || (l == x.l && r < x.r);
  }
};
node a[1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].l, &a[i].r);
    if (a[i].l > a[i].r) swap(a[i].l, a[i].r);
  }
  sort(a, a + n);
  int ans = 0;
  a[n++].l = 1000000;
  for (int i = 1; i < n; ++i)
    if (a[i].l > a[i - 1].r) {
      path[ans++] = a[i - 1].r;
    } else {
      a[i].r = min(a[i - 1].r, a[i].r);
    }
  printf("%d\n", ans);
  int flag = 0;
  for (int i = 0; i < ans; ++i) {
    if (flag++) printf(" ");
    printf("%d", path[i]);
  }
  return 0;
}
