#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int n, x, y;
struct node {
  int l, r;
} a[1005];
bool cmp(node a, node b) {
  if (a.l != b.l)
    return a.l < b.l;
  else
    return a.r < b.r;
}
vector<int> v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].l >> a[i].r;
    if (a[i].l > a[i].r) swap(a[i].l, a[i].r);
  }
  sort(a + 1, a + n + 1, cmp);
  int ans = 1;
  int pos = a[1].r;
  for (int i = 2; i <= n; i++) {
    if (a[i].l > pos) {
      ans++;
      v.push_back(pos);
      pos = a[i].r;
    } else
      pos = min(pos, a[i].r);
  }
  v.push_back(pos);
  cout << ans << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
}
