#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)1e3 + 10;
int n;
pair<int, int> v[MAX_N];
vector<int> answer;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &v[i].first, &v[i].second);
    if (v[i].first > v[i].second) {
      swap(v[i].first, v[i].second);
    }
  }
  sort(v, v + n);
  int l = v[0].first, r = v[0].second;
  for (int i = 1; i < n; ++i) {
    if (v[i].first <= r) {
      l = v[i].first;
      r = min(r, v[i].second);
    } else {
      answer.push_back(l);
      l = v[i].first;
      r = v[i].second;
    }
  }
  answer.push_back(l);
  printf("%d\n", (int)answer.size());
  for (__typeof((answer).begin()) e = (answer).begin(); e != (answer).end();
       ++e) {
    printf("%d%c", *e, e == --answer.end() ? '\n' : ' ');
  }
}
