#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
struct node {
  int l, r;
} x[N];
bool com(node k1, node k2) { return k1.l < k2.l; }
vector<int> v;
int main() {
  int n, i, Min;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x[i].l, &x[i].r);
    if (x[i].l > x[i].r) swap(x[i].l, x[i].r);
  }
  sort(x + 1, x + n + 1, com);
  Min = x[1].r;
  for (i = 2; i <= n; i++) {
    if (x[i].l <= Min)
      Min = min(Min, x[i].r);
    else {
      v.push_back(Min);
      Min = x[i].r;
    }
  }
  v.push_back(Min);
  printf("%d\n", v.size());
  for (i = 0; i < v.size(); i++) printf("%d ", v[i]);
}
