#include <bits/stdc++.h>
using namespace std;
long long wts[20005], vis[1005];
int32_t main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<long long> ans;
  pair<long long, long long> a[n];
  for (long long 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, a + n);
  for (long long i = 0; i < n; i++) {
    if (vis[i]) continue;
    for (long long j = 0; j < n; j++) {
      if (a[j].second <= a[i].first) vis[j] = 1;
    }
    ans.push_back(a[i].first);
  }
  cout << ans.size() << "\n";
  for (long long i : ans) cout << i << " ";
}
