You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is considered to be nailed too. What is the smallest number of nails needed to nail all the segments down?

Input

The first line of the input contains single integer number n (1 ≤ n ≤ 1000) — amount of segments. Following n lines contain descriptions of the segments. Each description is a pair of integer numbers — endpoints coordinates. All the coordinates don't exceed 10000 by absolute value. Segments can degenarate to points.

Output

The first line should contain one integer number — the smallest number of nails needed to nail all the segments down. The second line should contain coordinates of driven nails separated by space in any order. If the answer is not unique, output any.

Examples

Input

2
0 2
2 5


Output

1
2 

Input

5
0 3
4 2
4 8
8 10
7 7


Output

3
7 10 3
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
clock_t start = clock();
long long int gcd(long long int a, long long int b) {
  return (a == 0) ? b : gcd(b % a, a);
}
long long int power(long long int a, long long int n) {
  long long int p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
long long int powm(long long int a, long long int n, long long int mod_) {
  long long int p = 1;
  while (n) {
    if (n % 2) {
      p = (((p % mod_) * 1LL * (a % mod_)) % mod_);
    }
    n >>= 1;
    a = (((a % mod_) * 1LL * (a % mod_)) % mod_);
  }
  return p % mod_;
}
long long int powi(long long int a, long long int mod_) {
  return powm(a, mod_ - 2, mod_);
}
bool cmp(pair<long long int, long long int> a,
         pair<long long int, long long int> b) {
  if (a.second != b.second) return a.second < b.second;
  return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int mn, mx;
  long long int n, m, k, t, i, j, sum = 0, flag = 0, cnt = 0;
  long long int x = 0, y = 0, z, l = 0, r = 0, q;
  int TC = 1;
  while (TC--) {
    cin >> n;
    vector<pair<long long int, long long int> > a(n);
    for (i = 0; i < n; ++i) {
      cin >> a[i].first >> a[i].second;
      if (a[i].first > a[i].second) swap(a[i].first, a[i].second);
    }
    vector<long long int> ans;
    sort((a).begin(), (a).end(), cmp);
    for (i = 0; i < n; ++i) {
      if (ans.empty() or ans.back() < a[i].first) ans.push_back(a[i].second);
    }
    cout << (long long int)((ans).size()) << '\n';
    for (auto x : ans) cout << x << ' ';
  };
  return 0;
}
