#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + "," +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug(T...);
}
struct Fast_power {
  long long integer(long long n, long long e,
                    long long my_mod = 9223372036854775807LL) {
    long long ans = 1;
    while (e) {
      if (e & 1)
        ans = (ans * n) % my_mod, e--;
      else
        n = (n * n) % my_mod, e >>= 1;
    }
    return ans;
  }
  vector<vector<long long>> matrix_multiply(vector<vector<long long>> a,
                                            vector<vector<long long>> b) {
    vector<vector<long long>> c(a.size(), vector<long long>(b[0].size(), 0));
    for (int i = 0; i < a.size(); i++)
      for (int q = 0; q < b[0].size(); q++) {
        long long num = 0;
        for (int e = 0; e < a[0].size(); i++) num += a[i][e] * b[e][q];
        c[i][q] = num;
      }
    return c;
  }
};
struct Euclidean {
  int gcdi(int a, int b) { return b ? gcdi(b, a % b) : a; }
  double gcdf(double a, double b, double accuracy) {
    return b <= accuracy ? a : gcdf(b, fmod(a, b), accuracy);
  }
};
const int maxnD = 100000 + 5;
const long long INFD = 0x3f3f3f3f;
;
struct Dijkstra {
  struct Edge {
    int from, to;
    long long dist;
  };
  struct HeapNode {
    long long d;
    int u;
    bool operator<(const HeapNode &rhs) const { return d > rhs.d; }
  };
  vector<Edge> edges;
  vector<int> G[maxnD];
  bool done[maxnD];
  long long d[maxnD];
  int p[maxnD], n;
  void init(int n) {
    this->n = n;
    for (int i = 0; i <= n; i++) G[i].clear();
    edges.clear();
  }
  void AddEdge(int from, int to, long long dist) {
    edges.push_back((Edge){from, to, dist});
    int m = edges.size();
    G[from].push_back(m - 1);
  }
  void dijkstra(int s) {
    priority_queue<HeapNode> q;
    memset(d, INFD, sizeof(d));
    d[s] = 0;
    memset(done, 0, sizeof(done));
    q.push((HeapNode){0, s});
    while (!q.empty()) {
      HeapNode x = q.top();
      q.pop();
      int u = x.u;
      if (done[u]) continue;
      done[u] = true;
      for (int i = 0; i < G[u].size(); i++) {
        Edge &e = edges[G[u][i]];
        if (d[e.to] > d[u] + e.dist) {
          d[e.to] = d[u] + e.dist;
          p[e.to] = G[u][i];
          q.push((HeapNode){d[e.to], e.to});
        }
      }
    }
  }
};
const int maxnL = 500000 + 5;
const int INFL = 0x3f3f3f3f;
struct LIS {
  int g[maxnL], a[maxnL], d[maxnL];
  void lis(int n) {
    for (int i = 1; i <= n; i++) g[i] = INFL;
    for (int i = 1; i < n; i++) {
      int k = lower_bound(g + 1, g + n + 1, a[i]) - g;
      g[k] = a[i];
    }
  }
};
const long long int INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000 + 5;
struct Node {
  int l, r;
  bool operator<(const Node &rhs) const { return l < rhs.l; }
} a[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].l >> a[i].r;
  sort(a, a + n);
  multiset<int> s;
  int ans = 0;
  int num;
  for (int i = 0; i < n; i++) {
    s.insert(a[i].r);
    while (*s.begin() <= a[i].l) s.erase(s.begin());
    if (s.size() > ans) ans = s.size(), num = a[i].l;
  }
  cout << num << " " << ans << endl;
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

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;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + "," +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug(T...);
}
struct Fast_power {
  long long integer(long long n, long long e,
                    long long my_mod = 9223372036854775807LL) {
    long long ans = 1;
    while (e) {
      if (e & 1)
        ans = (ans * n) % my_mod, e--;
      else
        n = (n * n) % my_mod, e >>= 1;
    }
    return ans;
  }
  vector<vector<long long>> matrix_multiply(vector<vector<long long>> a,
                                            vector<vector<long long>> b) {
    vector<vector<long long>> c(a.size(), vector<long long>(b[0].size(), 0));
    for (int i = 0; i < a.size(); i++)
      for (int q = 0; q < b[0].size(); q++) {
        long long num = 0;
        for (int e = 0; e < a[0].size(); i++) num += a[i][e] * b[e][q];
        c[i][q] = num;
      }
    return c;
  }
};
struct Euclidean {
  int gcdi(int a, int b) { return b ? gcdi(b, a % b) : a; }
  double gcdf(double a, double b, double accuracy) {
    return b <= accuracy ? a : gcdf(b, fmod(a, b), accuracy);
  }
};
const int maxnD = 100000 + 5;
const long long INFD = 0x3f3f3f3f;
;
struct Dijkstra {
  struct Edge {
    int from, to;
    long long dist;
  };
  struct HeapNode {
    long long d;
    int u;
    bool operator<(const HeapNode &rhs) const { return d > rhs.d; }
  };
  vector<Edge> edges;
  vector<int> G[maxnD];
  bool done[maxnD];
  long long d[maxnD];
  int p[maxnD], n;
  void init(int n) {
    this->n = n;
    for (int i = 0; i <= n; i++) G[i].clear();
    edges.clear();
  }
  void AddEdge(int from, int to, long long dist) {
    edges.push_back((Edge){from, to, dist});
    int m = edges.size();
    G[from].push_back(m - 1);
  }
  void dijkstra(int s) {
    priority_queue<HeapNode> q;
    memset(d, INFD, sizeof(d));
    d[s] = 0;
    memset(done, 0, sizeof(done));
    q.push((HeapNode){0, s});
    while (!q.empty()) {
      HeapNode x = q.top();
      q.pop();
      int u = x.u;
      if (done[u]) continue;
      done[u] = true;
      for (int i = 0; i < G[u].size(); i++) {
        Edge &e = edges[G[u][i]];
        if (d[e.to] > d[u] + e.dist) {
          d[e.to] = d[u] + e.dist;
          p[e.to] = G[u][i];
          q.push((HeapNode){d[e.to], e.to});
        }
      }
    }
  }
};
const int maxnL = 500000 + 5;
const int INFL = 0x3f3f3f3f;
struct LIS {
  int g[maxnL], a[maxnL], d[maxnL];
  void lis(int n) {
    for (int i = 1; i <= n; i++) g[i] = INFL;
    for (int i = 1; i < n; i++) {
      int k = lower_bound(g + 1, g + n + 1, a[i]) - g;
      g[k] = a[i];
    }
  }
};
const long long int INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000 + 5;
struct Node {
  int l, r;
  bool operator<(const Node &rhs) const { return l < rhs.l; }
} a[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].l >> a[i].r;
  sort(a, a + n);
  multiset<int> s;
  int ans = 0;
  int num;
  for (int i = 0; i < n; i++) {
    s.insert(a[i].r);
    while (*s.begin() <= a[i].l) s.erase(s.begin());
    if (s.size() > ans) ans = s.size(), num = a[i].l;
  }
  cout << num << " " << ans << endl;
  return 0;
}

```