#include <bits/stdc++.h>
using namespace std;
inline int Mid(int a, int b) { return (a + b) >> 1; }
int n;
struct node {
  int x, y;
} a[2105];
bool cmp(node a, node b) {
  if (a.y == b.y) return a.x < b.x;
  return a.y < b.y;
}
vector<int> ans;
int h[2105];
int main() {
  int i, j;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) {
      cin >> a[i].x >> a[i].y;
      if (a[i].x > a[i].y) swap(a[i].x, a[i].y);
    }
    memset(h, 0, sizeof h);
    sort(a + 1, a + n + 1, cmp);
    ans.clear();
    for (i = 1; i <= n; i++)
      if (!h[i]) {
        ans.push_back(a[i].y);
        for (j = i; j <= n; j++) {
          if (a[j].x <= a[i].y && a[i].y <= a[j].y) h[j] = 1;
        }
      }
    cout << ans.size() << endl;
    for (i = 0; i < ans.size(); i++)
      printf("%d%c", ans[i], i == ((int)ans.size() - 1) ? '\n' : ' ');
  }
  return 0;
}
