#include <bits/stdc++.h>
using namespace std;
int n;
bool used[1200];
int a[1200], b[1200];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  vector<int> R;
  int cnt = 0;
  while (cnt < n) {
    bool found = false;
    int c;
    for (int i = 0; i < n; ++i)
      if (!used[i] && (found == false || c > b[i])) {
        c = b[i];
        found = true;
      }
    for (int i = 0; i < n; ++i)
      if (!used[i] && (a[i] <= c && c <= b[i])) {
        ++cnt;
        used[i] = true;
      }
    R.push_back(c);
  }
  printf("%d\n", (int)R.size());
  for (int i = 0; i < (int)R.size(); ++i)
    printf("%d%c", R[i], i == (int)R.size() - 1 ? '\n' : ' ');
  return 0;
}
