#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::istream;
using std::map;
using std::ostream;
using std::set;
using std::string;
using std::vector;
ostream &operator<<(ostream &os, const unsigned char v) {
  os << (int)v;
  return os;
}
istream &operator>>(istream &is, unsigned char &v) {
  int tmp;
  is >> tmp;
  v = (unsigned char)tmp;
  return is;
}
inline unsigned char min(unsigned char a, unsigned char b) {
  return (a < b) ? a : b;
}
inline unsigned char max(unsigned char a, unsigned char b) {
  return (a > b) ? a : b;
}
int pmod(int a, int b) {
  if (b < 0) {
    return pmod(-a, -b);
  }
  int ret = a % b;
  if (ret < 0) ret += b;
  return ret;
}
int n;
std::pair<int, int> coords[1000];
bool cmp_coord(const std::pair<int, int> &c1, const std::pair<int, int> &c2) {
  return c1.second < c2.second;
}
int main(int argc, const char *argv[]) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x1, x2;
    cin >> x1 >> x2;
    coords[i].first = std::min(x1, x2);
    coords[i].second = std::max(x1, x2);
  }
  std::sort(coords, coords + n, cmp_coord);
  std::vector<int> nails;
  for (int i = 0; i < n;) {
    int e = coords[i].second;
    nails.push_back(e);
    int j = i + 1;
    while (j < n && coords[j].first <= e) j += 1;
    i = j;
  }
  cout << nails.size() << endl;
  for (int i = 0; i < nails.size(); i++) {
    cout << nails[i] << " ";
  }
  return 0;
}
