#include <bits/stdc++.h>
using namespace std;
int n, l[1010], r[1010], k[1010], ans[1010], ansk = 0;
bool ok[1010];
bool con(int a, int b) { return r[a] < r[b]; }
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    if (l[i] > r[i]) {
      k[i] = l[i];
      l[i] = r[i];
      r[i] = k[i];
    }
    k[i] = i;
  }
  sort(k, k + n, con);
  for (int i = 0; i < n; i++)
    if (!ok[k[i]]) {
      ans[ansk] = r[k[i]];
      ansk++;
      for (int j = 0; j < n; j++)
        if ((r[k[i]] >= l[j]) and (r[k[i]] <= r[j])) ok[j] = 1;
    }
  cout << ansk << endl;
  for (int i = 0; i < ansk; i++) cout << ans[i] << " ";
}
