#include <bits/stdc++.h>
const int inf = ~0U >> 1, maxn = 1000;
using namespace std;
struct Seg {
  int l, r;
  Seg() {}
  Seg(int _l, int _r) {
    l = _l;
    r = _r;
    if (l > r) swap(l, r);
  }
} A[maxn];
int main() {
  int n;
  int l, r;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> l >> r, A[i] = Seg(l, r);
  int Last = -inf, cnt = 0;
  vector<int> Ans;
  bool Mark[maxn] = {};
  for (;;) {
    int Min = -1;
    for (int i = 0; i < n; i++)
      if (!Mark[i] && (Min == -1 || A[i].r < A[Min].r)) Min = i;
    if (Min == -1) break;
    int x = A[Min].r;
    Ans.push_back(x);
    for (int i = 0; i < n; i++)
      if (!Mark[i] && x >= A[i].l && x <= A[i].r) Mark[i] = true;
  }
  cout << Ans.size() << endl;
  for (int i = 0; i < Ans.size(); i++) cout << Ans[i] << " ";
  cout << endl;
}
