#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
const long long INF = 2009000999;
const double cp = 2 * asin(1.0);
const double eps = 1e-9;
const long long mod = 1000000007LL;
using namespace std;
int n, a, b, ost = -INF;
vector<int> wyn;
pair<int, int> T[1010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    T[i] = make_pair(b, a);
  }
  sort(T + 1, T + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (ost < T[i].second) {
      wyn.push_back(T[i].first);
      ost = T[i].first;
    }
  }
  printf("%d\n", wyn.size());
  for (int i = 0; i < wyn.size(); i++) printf("%d ", wyn[i]);
  printf("\n");
  return 0;
}
