#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> res;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    if (y[i] < x[i]) swap(x[i], y[i]);
  }
  vector<pair<int, int> > yy;
  for (int i = 0; i < n; ++i) yy.push_back(make_pair(y[i], x[i]));
  sort(yy.begin(), yy.end());
  for (int i = 0; i < n; ++i) {
    x[i] = yy[i].second;
    y[i] = yy[i].first;
  }
  int hist[1000] = {0};
  for (int i = 0; i < n; ++i) {
    bool ok = true;
    for (int j = 0; j < n; ++j)
      if (!hist[j] && y[j] < y[i]) ok = false;
    if (ok) continue;
    int q = i - 1;
    for (int j = 0; j < n; ++j)
      if (!hist[j] && x[j] <= y[q] && y[q] <= y[j]) hist[j] = 1;
    res.push_back(y[q]);
  }
  bool ok = true;
  for (int j = 0; j < n; ++j)
    if (!hist[j]) ok = false;
  if (!ok) res.push_back(y[n - 1]);
  cout << res.size() << "\n";
  for (int i = 0; i < res.size(); ++i) cout << res[i] << " ";
  return 0;
}
