#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e3;
pair<long long, pair<bool, int> > events[2 * MAXN];
enum nailed_t { NOT = 0, WAITING, NAILED };
nailed_t nailed[MAXN];
vector<long long> nail;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long left, right;
    cin >> left >> right;
    if (left > right) {
      swap(left, right);
    }
    events[2 * i] = make_pair(left, make_pair(false, i));
    events[2 * i + 1] = make_pair(right, make_pair(true, i));
  }
  sort(events, events + 2 * n);
  memset(nailed, NOT, sizeof(nailed_t) * n);
  int opened = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (nailed[events[i].second.second] == WAITING ||
        nailed[events[i].second.second] == NAILED) {
      --opened;
      if (nailed[events[i].second.second] == WAITING) {
        nail.push_back(events[i].first);
        for (int j = 0; j < n; ++j) {
          if (nailed[j] == WAITING) {
            nailed[j] = NAILED;
          }
        }
      }
      continue;
    }
    opened++;
    nailed[events[i].second.second] = WAITING;
  }
  cout << nail.size() << endl;
  for (int i = 0; i < nail.size(); ++i) {
    cout << nail[i] << ' ';
  }
  return 0;
}
