#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10, INF = 1e9;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -f;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     return x * f;   }   int n, l[N], r[N], a[N], b[N], c[N];   int ans, sum, pos, cnt, tot;   int t1, t2;   signed main() {     n = read();     for (int i = 1; i <= n; i++) {       l[i] = read();       r[i] = read();       a[++cnt] = l[i];       a[++cnt] = r[i];     }     sort(a + 1, a + cnt + 1);     for (int i = 1; i <= cnt; i++)       if (i == 1 || a[i] != a[i - 1]) a[++tot] = a[i];     for (int i = 1; i <= n; i++) {       t1 = lower_bound(a + 1, a + tot + 1, l[i]) - a;       t2 = lower_bound(a + 1, a + tot + 1, r[i]) - a;       c[t1] = l[i], c[t2] = r[i];       b[t1]++, b[t2]--;     }     for (int i = 1; i <= tot; i++) {       sum += b[i];       if (sum > ans) ans = sum, pos = c[i];     }     printf( %d %d , pos, ans);     return 0;   }   