#include <bits/stdc++.h>
using namespace std;
int countPoints(vector<pair<int, int> > a, int x, int pos) {
  int n = a.size();
  int count = 0;
  for (int i = pos; i < n; i++) {
    if (a[i].first <= x && a[i].second >= x)
      count++;
    else
      break;
  }
  return count;
}
int main() {
  int n = 0;
  cin >> n;
  vector<pair<int, int> > a;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    if (a[i].first > a[i].second) swap(a[i].first, a[i].second);
  }
  sort(a.begin(), a.end());
  vector<int> res;
  for (int i = 0; i < n; i++) {
    int maxp = 0;
    int maxi = -1;
    for (int j = a[i].first; j <= a[i].second; j++) {
      int count = countPoints(a, j, i);
      if (maxp < count) {
        maxp = count;
        maxi = j;
      }
    }
    if (maxi != -1) res.push_back(maxi);
    i += maxp - 1;
  }
  int m = res.size();
  cout << m << endl;
  for (int i = 0; i < m; i++) {
    if (i != m - 1)
      cout << res[i] << " ";
    else
      cout << res[i] << endl;
  }
  return 0;
}
