#include <bits/stdc++.h>
using namespace std;
const int OO = (int)2e9;
const double PI = 2 * acos(0);
const double EPS = 1e-9;
int vis[10001];
int n;
bool f(pair<int, int> x, pair<int, int> y) { return y.second > x.second; }
int main() {
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < (int)n; i++) {
    cin >> v[i].first >> v[i].second;
    if (v[i].first > v[i].second) swap(v[i].second, v[i].first);
  }
  sort(v.begin(), v.end(), f);
  int ret = 0;
  vector<int> res;
  for (int i = 0; i < (int)n; i++) {
    if (!vis[i]) {
      ret++;
      int end = v[i].second;
      res.push_back(end);
      for (int j = 0; j < (int)n; j++)
        if (end >= v[j].first && end <= v[j].second) vis[j] = 1;
    }
  }
  cout << ret << endl;
  for (int i = 0; i < (int)ret; i++) cout << res[i] << " ";
  return 0;
}
