#include <bits/stdc++.h>
using namespace std;
struct otr {
  int lf, rt;
  bool used;
};
otr a[1002];
int n, ans = 0, k = 0, b[1002], x, y;
int main() {
  scanf("%i", &n);
  for (int i = 0; i < n; i++) {
    scanf("%i %i", &x, &y);
    if (x < y) {
      a[i].lf = x;
      a[i].rt = y;
    } else {
      a[i].lf = y;
      a[i].rt = x;
    }
    a[i].used = false;
  }
  while (k != n) {
    int min = 20000;
    for (int i = 0; i < n; i++) {
      if (a[i].rt < min && !a[i].used) min = a[i].rt;
    }
    b[ans] = min;
    ans++;
    for (int i = 0; i < n; i++) {
      if (min <= a[i].rt && min >= a[i].lf && !a[i].used) {
        a[i].used = true;
        k++;
      }
    }
  }
  printf("%i\n", ans);
  for (int i = 0; i < ans; i++) printf("%i ", b[i]);
  return 0;
}
