#include <bits/stdc++.h>
using namespace std;
int a, s, d, f, g, h, j, k, l, i, n, m;
pair<int, int> p[1002];
vector<int> v;
stack<int> q;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    if (p[i].second < p[i].first) swap(p[i].second, p[i].first);
  }
  sort(p, p + n);
  q.push(p[0].second);
  for (i = 1; i < n; i++) {
    if (p[i].first > q.top()) {
      v.push_back(q.top());
      while (!q.empty()) q.pop();
    }
    if (q.empty() || q.top() > p[i].second) q.push(p[i].second);
  }
  if (!q.empty()) v.push_back(q.top());
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
}
