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 \le n \le 10^5$) — the number of people.

Each of the following $n$ lines contain two integers $b$ and $d$ ($1 \le b \lt d \le 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.

Difficulty: interview

Starter code:

Solutions:
n = int(input())

mp = {}

for _ in range(n):
    a, b = map(int, input().split())
    mp[a] = mp.get(a, 0) + 1
    mp[b] = mp.get(b, 0) - 1

cur = 0
maxi = 0
maxiy = 0

for i in sorted(mp):
    cur += mp[i]

    if cur > maxi:
        maxi = cur
        maxiy = i

print(maxiy, maxi)

# Program to find maximum guest
# at any time in a party
def findMaxGuests(arrl, exit, n):
    # Sort arrival and exit arrays
    arrl.sort()
    exit.sort()

    # guests_in indicates number of
    # guests at a time
    guests_in = 1
    max_guests = 1
    time = arrl[0]
    i = 1
    j = 0

    # Similar to merge in merge sort to
    # process all events in sorted order
    while (i < n and j < n):

        # If next event in sorted order is
        # arrival, increment count of guests
        if (arrl[i] <= exit[j]):

            guests_in = guests_in + 1

            # Update max_guests if needed
            if (guests_in > max_guests):
                max_guests = guests_in
                time = arrl[i]

            # increment index of arrival array
            i = i + 1

        else:
            guests_in = guests_in - 1
            j = j + 1

    print( time,max_guests)


# Driver Code
t=int(input())
arrl=[]
exit=[]
for _ in range(t):
    a,b=list(map(int,input().strip().split(" ")))
    arrl.append(a)
    exit.append(b-1)
n = len(arrl)
findMaxGuests(arrl, exit, n)

# This code is contributed
# by Shivi_Aggarwal


from bisect import bisect_right
n = int(input())
bs = []
ds = []
for i in range(n):
    b, d = map(int, input().split())
    bs.append(b)
    ds.append(d)
bs.sort()
ds.sort()
maxpop = 0
bestyear = 0
for i in range(len(bs)):
    died_at_this_point = bisect_right(ds, bs[i])
    if maxpop < i+1 - died_at_this_point:
        maxpop = i+1 - died_at_this_point
        bestyear = bs[i]
print(bestyear, maxpop)

from sys import stdin
 
def input():
    return stdin.readline().strip()

n = int(input())
birth_arr = []
death_arr = []
for i in range(n):
    b, d = list(map(int, input().split()))
    birth_arr.append(b)
    death_arr.append(d)

birth_arr = sorted(birth_arr)
death_arr = sorted(death_arr)

num_ppl = len(birth_arr)
curr = 0
curr_year = 0
max_year = None
max_ppl = 0
b_pointer = 0
d_pointer = 0

while b_pointer < num_ppl:
    if birth_arr[b_pointer] < death_arr[d_pointer]:
        curr += 1
        curr_year = birth_arr[b_pointer]
        if curr > max_ppl:
            max_year = curr_year
            max_ppl = curr
        b_pointer += 1
    elif birth_arr[b_pointer] == death_arr[d_pointer]:
        curr_year = birth_arr[b_pointer]
        b_pointer += 1
        d_pointer += 1
    else:
        curr -= 1
        curr_year = death_arr[d_pointer]
        d_pointer += 1

print(f"{max_year} {max_ppl}")

n = int(input())
a = []
for i in range(n):
    x, y = list(map(int, input().split()))
    a.append([x, 1])
    a.append([y, 0])
a.sort()
c = 0
m = 0
y = 0
for i in range(len(a)):
    if a[i][1] == 1:
        c += 1
    else:
        c -= 1
    if m < c:
        m = c
        y = a[i][0]
print(y, m)




import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)
def put():  return  map(int, stdin.readline().split())
for _ in range(1):
	n=int(input())
	start=[]
	end=[]
	for i in range(n):
		a,b=put()
		start.append(a)
		end.append(b)
	start.sort()
	end.sort()
	numalive=0
	startyear=0
	indstart=0
	indend=0
	mx=0
	while(indstart<n ):
		if(start[indstart]<end[indend]):
			numalive+=1
			indstart+=1
			if(numalive>mx):
				mx=max(mx,numalive)
				startyear=start[indstart-1]
		elif(start[indstart]==end[indend]):
			indstart+=1
			indend+=1
		else:
			numalive-=1
			indend+=1
	print(startyear,mx)

n = int(input())
interv = []
for i in range(n):
   deb, fin = list(map(int, input().split()))
   interv.append((deb, +1))
   interv.append((fin, -1))

interv.sort()

m = 0
y = 0
c = 0
for (t, dx) in interv:
   c += dx
   if c > m:
      m = c
      y = t
print(y, m)


n = int(input())
l1 = []
l2 = []
for i in range(n):
    a,b = map(int,input().split())
    l1.append(a)
    l2.append(b)

l1.sort(reverse=True)
l2.sort(reverse=True)

cur = 0
mx = 0
ans = 0

while l1:
    if l1[-1] < l2[-1]:
        t = l1.pop()
        cur += 1
        if cur > mx:
            mx = cur
            ans = t
    else:
        l2.pop()
        cur-=1

print(ans,mx)

n = int(input())
l1 = []
l2 = []
for i in range(n):
    a,b = list(map(int,input().split()))
    l1.append(a)
    l2.append(b)
l1.sort()
l2.sort()
ans = 0
kk = 0
c = 0
cc = 0
i = 0
while i<n:
    if l1[i]<l2[cc]:
        c+=1
        if c>ans:
            kk = l1[i]
            ans = c
        i+=1
    else:
        cc+=1
        c-=1
    
print(kk,ans)
    


n = int(input())
masb = []
masd = []
for i in range(n):
    z1, z2 = list(map(int, input().split()))
    masb.append(z1)
    masd.append(z2)
masb.sort()
masd.sort()
j = 0
k = 0
y = 0
mx = [0, 0]
for i in range(len(masb)):
    y = masb[i]
    k += 1
    while y >= masd[j]:
        k -= 1
        j += 1
    if k > mx[1]:
        mx = [y, k]
print(*mx)