#include <bits/stdc++.h>
using namespace std;
struct seg {
  int left, right;
} data[1000];
int ret[1000];
bool cmp(seg a, seg b) { return a.right < b.right; }
int main() {
  int n;
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &data[i].left, &data[i].right);
    if (data[i].left > data[i].right) {
      data[i].left ^= data[i].right;
      data[i].right ^= data[i].left;
      data[i].left ^= data[i].right;
    }
  }
  sort(data, data + n, cmp);
  int left = -999999;
  int m = 0;
  for (i = 0; i < n; i++) {
    if (data[i].left > left) {
      ret[m++] = data[i].right;
      left = data[i].right;
    }
  }
  printf("%d\n", m);
  for (i = 0; i < m; i++) printf("%d ", ret[i]);
  printf("\n");
  return 0;
}
