#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 0LL;
long long MOD = 1e18 + 0LL;
long long md = 1000000007;
const double PI = acos(-1);
long long poW(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long b = poW(a, n / 2);
    return (b * b) % md;
  }
  return (poW(a, n - 1) * a) % md;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
bool isOdd(int n) { return (n % 2) != 0; }
template <class T>
void printVector(vector<T> &v, string s = "") {
  cout << s;
  for (int i = 0; i < ((int)((v).size())); i++) {
    cout << v[i] << ' ';
  }
  printf("\n");
}
int toInt(string str) {
  int num;
  istringstream iss(str);
  iss >> num;
  return num;
}
template <class T>
string toStr(T par) {
  ostringstream oss;
  oss << par;
  return oss.str();
}
void sieve(vector<int> &v) {
  int i, j;
  v.push_back(1);
  bool visit[1002];
  memset(visit, 0, sizeof(visit));
  for (i = 2; i <= 1001; i++) {
    if (!visit[i]) {
      for (j = i * i; j <= 1001; j += i) {
        visit[j] = 1;
      }
      v.push_back(i);
    }
  }
}
bool isPrime(int x) {
  if (x < 2) return false;
  for (int y = 2; y * y <= x; y++)
    if (x % y == 0) return false;
  return true;
}
bool trip(pair<int, pair<int, int> > p, pair<int, pair<int, int> > q) {
  int id1 = p.first;
  int id2 = q.first;
  int val1 = p.second.first;
  int val2 = q.second.first;
  int sid1 = p.second.second;
  int sid2 = q.second.second;
  if (id1 == id2) {
    return sid1 < sid2;
  }
  return val1 < val2;
}
long long maxSubArraySum(vector<int> &v) {
  long long sum = 0, mx = 0;
  for (int i = 0; i < ((int)((v).size())); i++) {
    sum = max((long long)v[i], sum + v[i]);
    mx = max(mx, sum);
  }
  return mx;
}
bool cmpl(pair<int, int> &p, pair<int, int> &q) {
  if (p.first != q.first) return p.first < q.first;
  return p.second < q.second;
}
bool cmpl2(pair<long long, long long> &p, pair<long long, long long> &q) {
  long long a = p.first;
  long long b = q.first;
  return min(a, p.second) > min(b, q.second);
}
int bins(int k, int n, vector<int> &v) {
  int lo = 0, hi = n - 1;
  while (lo <= hi) {
    int mid = (lo + hi + 1) / 2;
    if (v[mid] == k) return mid;
    if (v[mid] < k) {
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  return -1;
}
void printPair(vector<pair<int, int> > &v) {
  for (int i = 0; i < ((int)((v).size())); i++) {
    cout << v[i].first << ' ' << v[i].second << endl;
  }
}
void fnd(vector<long long> &a, vector<long long> &b, long long &mx) {
  int i, j, k;
  for (i = 0; i <= 5; i++) {
    j = 5 - i;
    long long s = 1LL;
    if (((int)((a).size())) < (i) || ((int)((b).size())) < (j)) continue;
    ;
    for (k = 0; k < i; k++) s *= a[k];
    for (k = 0; k < j; k++) s *= b[k];
    mx = max(s, mx);
  }
}
int main() {
  int cs = 0, tcs = 1;
  while (cs < tcs) {
    cs++;
    int n;
    cin >> n;
    int cur = 0;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
      int b, d;
      cin >> b >> d;
      v.push_back({b, 1});
      v.push_back({d, -1});
    }
    int yr = 1, maxi = 0;
    sort(((v).begin()), ((v).end()));
    for (int i = 0; i < (2 * n); i++) {
      cur += v[i].second;
      if (cur > maxi) {
        maxi = cur;
        yr = v[i].first;
      }
    }
    cout << yr << ' ' << maxi << "\n";
  }
}

### Prompt

Develop a solution in Cpp to the problem described below:

During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range (1, 10^9)! Therefore, the planet was named Longlifer.

In order to learn more about Longlifer's previous population, scientists need to determine the year with maximum number of individuals that were alive, as well as the number of alive individuals in that year. Your task is to help scientists solve this problem!

Input

The first line contains an integer n (1 ≤ n ≤ 10^5) — the number of people.

Each of the following n lines contain two integers b and d (1 ≤ b < d ≤ 10^9) representing birth and death year (respectively) of each individual.

Output

Print two integer numbers separated by blank character, y — the year with a maximum number of people alive and k — the number of people alive in year y.

In the case of multiple possible solutions, print the solution with minimum year.

Examples

Input


3
1 5
2 4
5 6


Output


2 2


Input


4
3 4
4 5
4 6
8 10


Output


4 2

Note

You can assume that an individual living from b to d has been born at the beginning of b and died at the beginning of d, and therefore living for d - b years.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 0LL;
long long MOD = 1e18 + 0LL;
long long md = 1000000007;
const double PI = acos(-1);
long long poW(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    long long b = poW(a, n / 2);
    return (b * b) % md;
  }
  return (poW(a, n - 1) * a) % md;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) return a.second > b.second;
  return a.first < b.first;
}
bool isOdd(int n) { return (n % 2) != 0; }
template <class T>
void printVector(vector<T> &v, string s = "") {
  cout << s;
  for (int i = 0; i < ((int)((v).size())); i++) {
    cout << v[i] << ' ';
  }
  printf("\n");
}
int toInt(string str) {
  int num;
  istringstream iss(str);
  iss >> num;
  return num;
}
template <class T>
string toStr(T par) {
  ostringstream oss;
  oss << par;
  return oss.str();
}
void sieve(vector<int> &v) {
  int i, j;
  v.push_back(1);
  bool visit[1002];
  memset(visit, 0, sizeof(visit));
  for (i = 2; i <= 1001; i++) {
    if (!visit[i]) {
      for (j = i * i; j <= 1001; j += i) {
        visit[j] = 1;
      }
      v.push_back(i);
    }
  }
}
bool isPrime(int x) {
  if (x < 2) return false;
  for (int y = 2; y * y <= x; y++)
    if (x % y == 0) return false;
  return true;
}
bool trip(pair<int, pair<int, int> > p, pair<int, pair<int, int> > q) {
  int id1 = p.first;
  int id2 = q.first;
  int val1 = p.second.first;
  int val2 = q.second.first;
  int sid1 = p.second.second;
  int sid2 = q.second.second;
  if (id1 == id2) {
    return sid1 < sid2;
  }
  return val1 < val2;
}
long long maxSubArraySum(vector<int> &v) {
  long long sum = 0, mx = 0;
  for (int i = 0; i < ((int)((v).size())); i++) {
    sum = max((long long)v[i], sum + v[i]);
    mx = max(mx, sum);
  }
  return mx;
}
bool cmpl(pair<int, int> &p, pair<int, int> &q) {
  if (p.first != q.first) return p.first < q.first;
  return p.second < q.second;
}
bool cmpl2(pair<long long, long long> &p, pair<long long, long long> &q) {
  long long a = p.first;
  long long b = q.first;
  return min(a, p.second) > min(b, q.second);
}
int bins(int k, int n, vector<int> &v) {
  int lo = 0, hi = n - 1;
  while (lo <= hi) {
    int mid = (lo + hi + 1) / 2;
    if (v[mid] == k) return mid;
    if (v[mid] < k) {
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  return -1;
}
void printPair(vector<pair<int, int> > &v) {
  for (int i = 0; i < ((int)((v).size())); i++) {
    cout << v[i].first << ' ' << v[i].second << endl;
  }
}
void fnd(vector<long long> &a, vector<long long> &b, long long &mx) {
  int i, j, k;
  for (i = 0; i <= 5; i++) {
    j = 5 - i;
    long long s = 1LL;
    if (((int)((a).size())) < (i) || ((int)((b).size())) < (j)) continue;
    ;
    for (k = 0; k < i; k++) s *= a[k];
    for (k = 0; k < j; k++) s *= b[k];
    mx = max(s, mx);
  }
}
int main() {
  int cs = 0, tcs = 1;
  while (cs < tcs) {
    cs++;
    int n;
    cin >> n;
    int cur = 0;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
      int b, d;
      cin >> b >> d;
      v.push_back({b, 1});
      v.push_back({d, -1});
    }
    int yr = 1, maxi = 0;
    sort(((v).begin()), ((v).end()));
    for (int i = 0; i < (2 * n); i++) {
      cur += v[i].second;
      if (cur > maxi) {
        maxi = cur;
        yr = v[i].first;
      }
    }
    cout << yr << ' ' << maxi << "\n";
  }
}

```