One of Chef's friends offered him a deal: during $D$ days, they are going to exchange money. For each $i$ ($1 \le i \le D$), on the $i$-th day, Chef's friend would give Chef $A$ rupees, while Chef would give his friend $2^{i-1}$ rupees ($1$ rupee on day $1$, $2$ rupees on day $2$, $4$ rupees on day $3$, and so on). Chef's profit from the deal is the total number of rupees he received from his friend minus the total number of rupees he gave his friend.
Chef decided to ask for your advice before accepting the deal. You want to help him by telling him two numbers $D_1$ and $D_2$, where $D_1$ is the maximum value of $D$ such that Chef should accept the deal, i.e. his profit from the deal is positive if $D = D_1$, and $D_2$ is the value of $D$ that leads to the maximum possible profit for Chef. If there are multiple values of $D$ that lead to the maximum profit, $D_2$ is the smallest of these values.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains a single integer $A$.

-----Output-----
For each test case, print a single line containing two space-separated integers $D_1$ and $D_2$.

-----Constraints-----
- $1 \le T \le 100,000$
- $5 \le A \le 10^9$

-----Subtasks-----
Subtask #1 (100 points): original constraints

-----Example Input-----
4
5
8
9
1000000000

-----Example Output-----
4 3
5 3
5 4
35 30

Difficulty: MEDIUM

Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	cs = 0
	fs = 0
	i = 0
	df = []
	while True:
		tc = cs + n
		tf = fs + pow(2, i)
		if fs > cs:
			break
		cs = tc
		fs = tf
		df.append(cs - fs)
		i += 1
	mx = max(df)
	print(i - 1, df.index(mx) + 1)


for _ in range(int(input())):
	n = int(input())
	c = 0
	f = 0
	i = 0
	q = []
	while c >= f:
		c += n
		f += 2 ** i
		q.append(c - f)
		i += 1
	m1 = q.index(max(q))
	print(i - 1, m1 + 1)


T = int(input())
for _ in range(T):
	A = int(input())
	f = True
	i = 1
	total_profit = 0
	profits = {}
	while f:
		chef_receives = A
		chef_gives = 2 ** (i - 1)
		profit = chef_receives - chef_gives
		total_profit += profit
		profits[i] = total_profit
		if total_profit < 0:
			f = False
			print(i - 1, end=' ')
		i += 1
	profits = sorted(profits.items(), key=lambda x: x[1], reverse=True)
	minimum = []
	for j in range(len(profits)):
		if profits[j][1] == profits[0][1]:
			minimum.append(profits[j][0])
		else:
			break
	print(min(minimum))


t = int(input())
while t > 0:
	n = int(input())
	g = 0
	i = 0
	x = 0
	d = 0
	h = 0
	p = 1
	mp = 0
	while p > 0:
		x = 1 << i
		g = g + x
		i += 1
		h = h + n
		p = h - g
		if mp < p:
			d = i
			mp = p
		if i > 50:
			break
	print(i - 1, d)
	t -= 1


import sys
input = sys.stdin.readline

def rii():
	return range(int(input().strip()))

def ii():
	return int(input().strip())

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())

def solve(a):
	(d1, d2) = (1, 1)
	(chef, friend) = (a, 1)
	best = chef - friend
	while chef > friend:
		d1 += 1
		chef += a
		friend += 2 ** (d1 - 1)
		if chef - friend > best:
			best = chef - friend
			d2 += 1
	return f'{d1 - 1} {d2}'

def do_codechef():
	for t in rii():
		a = ii()
		print(solve(a))
do_codechef()
exit()


def solution():
	A = int(input())
	D = 0
	D1 = 0
	D2 = 0
	max_profit = 0
	give = 0
	take = 0
	while take >= give:
		if max_profit < take - give:
			max_profit = take - give
			D2 = D
		D1 = D
		give += 1 << D
		take += A
		D += 1
	print(str(D1) + ' ' + str(D2))
T = int(input())
while T > 0:
	T = T - 1
	solution()


t = int(input())
for _ in range(t):
	a = int(input())
	d1 = 0
	d2 = 0
	n = 0
	profit = 0
	while True:
		n += 1
		calc = a * n - 2 ** n + 1
		maximum = max(calc, profit)
		if maximum > profit:
			d2 = n
		profit = calc
		if profit < 0:
			d1 = n - 1
			break
	print(d1, d2)


for _ in range(int(input())):
	a = int(input())
	D1 = 0
	D2 = [1, 1 - a]
	pd1 = a
	i = 1
	pd2 = 2 ** (i - 1)
	while pd1 + a > pd2 + 2 ** i:
		i += 1
		pd1 += a
		pd2 = pd2 + 2 ** (i - 1)
		if D2[1] < pd1 - pd2:
			D2[1] = pd1 - pd2
			D2[0] = i
	print(i, D2[0])


t = int(input())
for _ in range(t):
	a = int(input())
	profit = 0
	donate = 1
	day = 0
	counter = 0
	maxprofit = profit
	while profit >= 0:
		counter += 1
		profit += a - donate
		donate *= 2
		if profit > maxprofit:
			day = counter
		maxprofit = max(maxprofit, profit)
	last = counter
	print(last - 1, day)


from math import log
tc = int(input())
for _ in range(tc):
	a = int(input())
	d2 = int(log(a, 2) + 1)
	if int(log(a, 2)) == log(a, 2):
		d2 -= 1
	d1 = d2
	while True:
		if d1 * a >= 2 ** d1 - 1:
			d1 += 1
		else:
			d1 -= 1
			break
	print(d1, d2)


from bisect import bisect_left, bisect_right
import math
from bisect import bisect_left
from heapq import heapify, heappush, heappop
from collections import deque
import sys
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
from collections import deque, defaultdict
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

def ip():
	return input().strip()

def ii():
	return int(input())

def ot(in_p, *args, e=' '):
	if type(in_p) == list:
		print(*in_p, end=e)
	if type(in_p) == str or type(in_p) == int:
		print(in_p, end=e)
		for l in args:
			print(l, end=e)
	print()

def a_pwr_n(a, n, mod):
	if n == 1:
		return a % mod
	if n % 2 == 0:
		val = a_pwr_n(a, n // 2, mod)
		return val % mod * val % mod
	else:
		return a % mod * a_pwr_n(a, n - 1, mod) % mod

def rg(*ag):
	if len(ag) == 3:
		return range(ag[0], ag[1], ag[2])
	elif len(ag) == 2:
		return range(ag[0], ag[1])
	elif len(ag) == 1:
		return range(ag[0])
	else:
		raise 'invalid input'

def ispal(i, j, st):
	while i <= j:
		if st[i] == st[j]:
			i = i + 1
			j = j - 1
		else:
			return False
	return True
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]
for x in range(ii()):
	rup = ii()
	i = 1
	summ = 0
	d2 = 0
	d1 = 0
	fri = 0
	while i > 0:
		summ = summ + rup
		fri = fri + 2 ** (i - 1)
		if 2 ** (i - 1) < rup:
			d2 = d2 + 1
		if fri > summ:
			d1 = i - 1
			break
		i = i + 1
	print(d1, d2)


for _ in range(int(input())):
	a = int(input())
	give_tot = 0
	(gate, gate1) = (True, True)
	cnt = 0
	(d1, d2) = ('', '')
	while gate1 == True:
		cnt += 1
		gross_tot = a * cnt
		give = 2 ** (cnt - 1)
		give_tot += give
		if give_tot >= gross_tot and gate1 == True:
			d1 = cnt - 1
			gate1 = False
		if give >= a and gate == True:
			d2 = cnt - 1
			gate = False
	print(d1, d2)


t = int(input())
while t != 0:
	a = int(input())
	give = 0
	take = 0
	m = []
	i = 1
	while 1:
		give += 2 ** (i - 1)
		take += a
		if take - give <= 0:
			break
		else:
			m.append(take - give)
			i += 1
	d2 = m.index(max(m)) + 1
	d1 = len(m)
	print(d1, d2)
	t -= 1


t = int(input())
for _ in range(t):
	a = int(input())
	d1 = 0
	profit = 0
	i = 0
	while a - 2 ** i > 0:
		profit += a - 2 ** i
		i += 1
		d1 += 1
	d2 = d1
	while profit > 0:
		profit += a - 2 ** i
		i += 1
		d2 += 1
	print(d2 - 1, d1)


for i in range(int(input())):
	n = int(input())
	max_profit = 0
	d = 0
	m = 0
	give = 1
	mult = 1
	take = n
	while True:
		if give > take:
			break
		if max_profit < take - give:
			max_profit = take - give
			m += 1
		mult *= 2
		give += mult
		take += n
		d += 1
	print(d, end=' ')
	print(m)


t = int(input())
while t:
	n = int(input())
	A = 0
	x = 0
	y = -1
	tmp = 0
	i = 0
	d = 0
	while A > x or x == 0:
		tmp = y
		A += n
		x += 2 ** i
		y = max(y, A - x)
		if y == tmp and d == 0:
			d = i
		i += 1
	if A != x:
		i -= 1
	print(i, d)
	t -= 1


T = int(input())
for x in range(T):
	a = int(input())
	p = []
	i = 1
	v = 0
	while True:
		v += a - 2 ** (i - 1)
		if v >= 0:
			p.append(v)
		else:
			break
		i += 1
	print(len(p), p.index(max(p)) + 1)


for _ in range(int(input(''))):
	a = int(input())
	d = 1
	chef_get = 0
	chef_give = 0
	d1 = 0
	profit = 0
	profit1 = 0
	d2 = 0
	while True:
		chef_get = a * d
		chef_give = pow(2, d) - 1
		profit = chef_get - chef_give
		profit1 = a * (d - 1) - (pow(2, d - 1) - 1)
		if chef_get > chef_give:
			d1 = d
			if profit > profit1:
				d2 = d
			d += 1
			continue
		else:
			break
	print(d1, d2)


T = int(input())
for i in range(T):
	a = int(input())
	s = bin(a)
	d2 = len(s) - s.index('1')
	if 2 ** (d2 - 1) == a:
		d2 -= 1
	d1 = 0
	while d1 * a >= 2 ** d1 - 1:
		d1 += 1
	print(d1 - 1, d2)


try:
	t = int(input())
	for i in range(0, t):
		a = int(input())
		s = 0
		f = 0
		j = 1
		flist = []
		max = 0
		k = 0
		g = 1
		while g > 0:
			s = s + a
			f = f + 2 ** (j - 1)
			j = j + 1
			g = s - f
			if g > max:
				max = g
				k = j
		print(f'{j - 2} {k - 1}')
except:
	pass


t = int(input())
while t:
	a = int(input())
	(d1, d2, max) = (1, int(), 0)
	mt = a * d1
	mg = 2 ** d1 - 1
	while mt > mg:
		if mt - mg > max:
			max = mt - mg
			d2 = d1
		d1 = d1 + 1
		mt = a * d1
		mg = 2 ** d1 - 1
	print(d1 - 1, d2)
	t = t - 1


import math
for t in range(int(input())):
	a = int(input())
	(b, c, i, j) = (0, 0, 0, 0)
	while b < a:
		b = 2 ** i
		i += 1
	while c >= 0:
		c += a - 2 ** j
		j += 1
	print(j - 1, i - 1)


li = [1]
for i in range(1, 40):
	li.append(li[-1] * 2)
for i in range(int(input())):
	no = int(input())
	p = 0
	j = 0
	maxd = 0
	while True:
		if p < 0:
			break
		else:
			p += no - li[j]
		if no > li[j]:
			maxd = j
		j += 1
	print(j - 1, maxd + 1)


test = int(input())
for _ in range(test):
	a = int(input())
	s = 1
	s1 = a
	p = a - s
	d = 1
	b = []
	for i in range(2, 100):
		if p <= 0:
			d = i - 2
			break
		else:
			b.append(p)
			s += pow(2, i - 1)
			a += s1
			p = a - s
	print(d, b.index(max(b)) + 1)


for _ in range(int(input())):
	a = int(input())
	friendProfit = 0
	chefProfit = 0
	count = 0
	max_pro_day = 0
	max_prof = -1
	for i in range(1, 40):
		friendProfit += 2 ** (i - 1)
		chefProfit += a
		prof = chefProfit - friendProfit
		if prof > max_prof:
			max_prof = prof
			max_pro_day = count
		count += 1
		if chefProfit < friendProfit:
			break
	print(count - 1, max_pro_day + 1)


t = int(input())
for i in range(0, t):
	a = int(input())
	r = 1
	count = 0
	while r < a:
		r *= 2
		count += 1
	min = count
	r = 1
	sum = a
	sumr = 1
	count = 0
	while sumr <= sum:
		r *= 2
		sumr += r
		sum += a
		count += 1
	max = count
	print(max, end=' ')
	print(min)


for _ in range(int(input())):
	x = int(input())
	d2 = 0
	i = 0
	sum = 0
	while sum + (x - pow(2, i)) > 0:
		sum += x - pow(2, i)
		if x - pow(2, i) > 0:
			d2 += 1
		i = i + 1
	print(i, end=' ')
	print(d2)


for _ in range(int(input())):
	n = int(input())
	i = 0
	while pow(2, i) < n:
		i = i + 1
	dtwo = i
	j = 1
	while pow(2, j) - 1 < j * n:
		j = j + 1
	done = j - 1
	print(str(done) + ' ' + str(dtwo))


for _ in range(int(input())):
	a = int(input())
	start = 1
	(ftotal, cheftotal) = (0, 0)
	(d1, d2) = (0, 0)
	if a == 0:
		print(0, 0)
		continue
	while cheftotal + a > ftotal + start or cheftotal == 0:
		d2 += 1
		ftotal += start
		cheftotal += a
		if start < a:
			d1 += 1
		start *= 2
	print(d2, d1)


T = int(input())
for _ in range(T):
	A = int(input())
	total_ip = A
	total_op = 1
	total_profit = total_ip - total_op
	B = 1
	d1 = 1
	d2 = 1
	c = 1
	f = 1
	cprofit = A - B
	while total_profit >= 0:
		c = c + 1
		B = B * 2
		cprofit = A - B
		total_ip = total_ip + A
		total_op = total_op + B
		total_profit = total_ip - total_op
		if cprofit <= 0 and f != 0:
			f = 0
			d2 = c - 1
		if total_profit <= 0:
			d1 = c - 1
	print(d1, d2)


for _ in range(int(input())):
	A = int(input())
	C = 0
	X = len(f'{A - 1:b}')
	n = X
	while (1 << n) - 1 < n * A:
		n += 1
	print(n - 1, X)


def two(d):
	return 2 ** d - 1
for _ in range(int(input())):
	a = int(input())
	d = 1
	chef_acc = a * d - two(d)
	lst = []
	day = []
	while chef_acc >= 0:
		chef_acc = a * d - two(d)
		lst.append(chef_acc)
		day.append(d)
		d += 1
	print(day[-2], lst.index(max(lst)) + 1)


t = int(input())
for _ in range(t):
	a = int(input())
	max = 0
	D = 0
	i = 1
	while i * a > 2 ** i - 1:
		if i * a - (2 ** i - 1) > max:
			D = i
		max = i * a - (2 ** i - 1)
		i = i + 1
	print(i - 1, D)


n = int(input())
for i in range(n):
	q = int(input())
	a = q
	c = 0
	while a >= 1:
		c += 1
		a //= 2
		if 2 ** c == q:
			a = 0
	l = c
	while 2 ** l <= q * l:
		l += 1
	print(l - 1, c)


for _ in range(int(input())):
	a = int(input())
	temp = []
	i = 1
	while pow(2, i) - 1 <= a * i:
		temp.append(a * i - pow(2, i))
		i += 1
	print(i - 1, temp.index(max(temp)) + 1)


n = int(input())
for i in range(n):
	A = int(input())
	x = 0
	y = 0
	ans = 0
	maxval = 0
	ans2 = 0
	while y >= x:
		ans += 1
		x = x << 1 | (1 << 1) - 1
		y = A * ans
		if maxval < y - x:
			ans2 = ans
			maxval = y - x
	ans = ans - 1
	print(ans, ans2)


for _ in range(int(input())):
	a = int(input())
	total = 0
	(d1, d2) = (0, 0)
	for i in range(1, 37):
		temp = a - 2 ** (i - 1)
		total += temp
		if d2 == 0 and temp <= 0:
			d2 = i - 1
		if d1 == 0 and total <= 0:
			d1 = i - 1
		if d1 != 0 and d2 != 0:
			break
	print(d1, d2)


t = int(input())
for i in range(t):
	a = int(input())
	i = 1
	l = []
	p = 0
	dene = 0
	lene = 0
	while p >= 0:
		dene = dene + pow(2, i - 1)
		lene = lene + a
		p = lene - dene
		i = i + 1
		l.append(p)
	print(i - 2, l.index(max(l)) + 1)


for _ in range(int(input())):
	n = int(input())
	diff = 1
	gm = 0
	gmv = 0
	i = 0
	while diff > 0:
		i += 1
		s = '1' * i
		su = int(s, 2)
		diff = n * i - su
		if diff > gmv:
			gmv = diff
			gm = i
	print('%d %d' % (i - 1, gm))


for _ in range(int(input())):
	n = int(input())
	n1 = n
	m = 1
	m1 = m
	ma = 0
	co = 1
	c = 1
	while n1 > m1:
		n1 += n
		m *= 2
		m1 += m
		if ma < n1 - m1:
			ma = n1 - m1
			c = co
		co += 1
	print(n1 // n - 1, c + 1)


import math
bro = int(input())
for jyo in range(bro):
	gum = int(input())
	m = gum - 1
	(i, c, k) = (1, 1, 1)
	oil = m
	while m > 0:
		i = i + 1
		c = c * 2
		m = m + gum - c
		if m > oil:
			oil = m
			k = i
	print(i - 1, k)


cases = int(input())
for case in range(cases):
	ammount = int(input())
	day = 1
	maximum_return = 0
	best_day = None
	rupees_recieved = 0
	rupees_given = 0
	while rupees_recieved > rupees_given or day == 1:
		rupees_recieved += ammount
		rupees_given += 2 ** (day - 1)
		if rupees_recieved - rupees_given > maximum_return:
			maximum_return = rupees_recieved - rupees_given
			best_day = day
		day += 1
	print(str(day - 2) + ' ' + str(best_day))


tst = int(input())
for i in range(tst):
	a = int(input())
	d1 = 0
	d2 = 0
	s = 0
	t = 0
	for j in range(1, 1000000000):
		if a > 2 ** (j - 1):
			d2 = d2 + 1
		s = s + a
		t = t + 2 ** (j - 1)
		if t < s:
			d1 = d1 + 1
		else:
			break
	print(d1, d2)


t = int(input())
for j in range(t):
	n = int(input())
	sa = n
	sm = 1
	i = 2
	m = 0
	an = 0
	while sm <= sa:
		sm = 2 ** i - 1
		sa = sa + n
		i = i + 1
		d = sa - sm
		if d > m:
			m = d
			an = i
	print(i - 2, an - 1)


import numpy
for i in range(int(input())):
	a = int(input())
	(d1, d2, c) = (1, 1, 0)
	while d1 * a > 2 ** d1 - 1:
		if a <= 2 ** (d1 - 1) and c == 0:
			(d2, c) = (d1 - 1, c + 1)
		d1 += 1
	print(d1 - 1, d2)


t = int(input())
for i in range(t):
	a = int(input())
	i = 1
	D1 = 0
	D2 = 0
	smA = 0
	smC = 0
	while i > 0:
		smA += a
		smC += 2 ** (i - 1)
		if 2 ** (i - 1) < a:
			D1 += 1
		if smA < smC:
			D2 = i - 1
			break
		i += 1
	print(D2, D1)


t = int(input())
while t > 0:
	a = int(input())
	ta = 0
	gi = 0
	c = 1
	i = 0
	d = 0
	ma = 0
	while True:
		ta += a
		gi += c
		c *= 2
		i += 1
		if ta - gi > ma:
			ma = ta - gi
			d = i
		if ta - gi < 0:
			i -= 1
			break
	print(i, d)
	t -= 1


import math
for _ in range(int(input())):
	a = int(input())
	i = 1
	while True:
		if (2 ** i - 1) / i >= a:
			break
		i += 1
	j = 1
	e = 2.718281828459045
	while True:
		if a - 2 ** j <= 0:
			break
		j += 1
	D1 = i - 1
	D2 = j
	print(D1, D2)


t = int(input())
while t > 0:
	n = int(input())
	b = bin(n)
	l = len(b) - 2
	if b.count('1') == 1:
		l -= 1
	x = 1
	s = 0
	for i in range(36):
		s += n
		s -= x
		if s < 0:
			break
		x *= 2
	print(i, l)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	(i, m, c, d1) = (0, 0, 0, 0)
	while c >= 0:
		c += n - 2 ** i
		(d1, m) = (i + 1, c) if c > m else (d1, m)
		i += 1
	print(i - 1, d1)


t = int(input())
for i in range(t):
	a = int(input())
	j = 1
	ans = []
	while True:
		if a * j > 2 ** j - 1:
			j += 1
		else:
			ans.append(j - 1)
			break
	profit = 0
	k = 1
	while True:
		if a * k - (2 ** k - 1) > profit:
			profit = a * k - (2 ** k - 1)
			k += 1
		else:
			ans.append(k - 1)
			break
	print(*ans)


from math import log2, log
for _ in range(int(input())):
	a = int(input())
	d1 = int()
	n = 1
	d2 = int()
	while True:
		if n * a + 1 <= pow(2, n):
			break
		else:
			d1 = n
			n += 1
	n = int(log2(a / log(2)))
	dn = n * a - pow(2, n)
	n += 1
	dn1 = n * a - pow(2, n)
	if dn >= dn1:
		d2 = n - 1
	else:
		d2 = n
	print(d1, d2)


for _ in range(int(input())):
	a = int(input())
	d = 1
	d2 = []
	while 2 ** d - 1 <= a * d:
		d2.append(a * d - 2 ** d)
		d += 1
	print(d - 1, d2.index(max(d2)) + 1)


t = int(input())
for i in range(t):
	a = int(input())
	d = 1
	x = a - 1
	y = 1
	z = a - 1
	while z > 0:
		z = d * a - (2 ** d - 1)
		if z > x:
			x = z
			y = d
		d += 1
	print(d - 2, y)


import math
for _ in range(int(input())):
	a = int(input())
	powerOf2 = math.log2(a)
	d2 = int(powerOf2 + 1)
	d2 -= 1 if int(powerOf2) == powerOf2 else 0
	d1 = d2
	while True:
		if d1 * a >= 2 ** d1 - 1:
			d1 += 1
		else:
			d1 -= 1
			break
	print(d1, d2)


def fun(a):
	t1 = 1
	t2 = a
	p = a - 1
	pday = 1
	count = 1
	while t2 > t1:
		t2 += a
		t1 = 1 + 2 * t1
		if t2 - t1 > p:
			p = max(p, t2 - t1)
			pday = count
		count += 1
	return (count - 1, pday + 1)
try:
	t = int(input())
	for i in range(t):
		n = int(input())
		x = fun(n)
		print(x[0], x[1])
except Exception:
	pass


t = int(input())
for _ in range(t):
	a = int(input())
	(d_max, max_d) = (1, 0)
	(chef, friend) = (0, 0)
	max_sum = 0
	while 1:
		chef += a
		friend += 2 ** (d_max - 1)
		if chef - friend > max_sum:
			max_sum = chef - friend
			max_d = d_max
		if chef - friend <= 0:
			break
		else:
			d_max += 1
	print(d_max - 1, max_d)


tests = int(input())
for i in range(tests):
	A = int(input())
	friend = 0
	chef = 0
	max_profit = 0
	d1 = 0
	d2 = 0
	temp_profit = 1
	day = 0
	while temp_profit > 0:
		friend += A
		chef += 1 << day
		temp_profit = friend - chef
		if temp_profit > 0:
			d1 = day + 1
		if temp_profit > max_profit:
			d2 = day + 1
			max_profit = temp_profit
		day += 1
	print(d1, d2)


for _ in range(int(input())):
	n = int(input())
	chef = 1
	frnd = 0
	i = 0
	chefs = 0
	frnds = -1
	itemp = i
	while chefs <= frnd:
		frnd += n
		chef = 1 << i
		chefs += chef
		if frnd - chefs > frnds:
			frnds = frnd - chefs
			itemp = i + 1
		if chefs <= frnd:
			i += 1
	print(i, itemp)


for i in range(int(input())):
	A = int(input())
	(MaxP, P) = (0, 0)
	(Imp, Pp) = (None, None)
	n = 1
	Sum = 0
	while A * n - (2 ** (n - 1) + Sum) > 0:
		Sum += 2 ** (n - 1)
		Pp = n
		Diff = A * n - Sum
		if Diff > MaxP:
			MaxP = Diff
			Imp = n
		n += 1
	print(Pp, Imp)


for _ in range(int(input())):
	a = int(input())
	c = 1
	d = 1
	ans = []
	while c < d * a:
		ans.append(d * a - c)
		c += 2 ** d
		d += 1
	t_1 = ans.index(max(ans)) + 1
	print(d - 1, t_1, sep=' ')


for _ in range(int(input())):
	A = int(input())
	x = 1
	pro = 0
	n = 0
	d = 1
	s = 0
	while True:
		n += 1
		s += x
		y = A * n - s
		if pro < y:
			pro = y
			d = n
		if y < 0:
			break
		x = x * 2
	print(n - 1, d)


for _ in range(int(input())):
	A = int(input())
	sumchef = 1
	sumfriend = A
	cnt = 0
	maxi = 0
	m = 0
	while sumfriend > sumchef:
		if maxi < sumfriend - sumchef:
			m += 1
			maxi = sumfriend - sumchef
		sumchef += 2 ** (cnt + 1)
		sumfriend += A
		cnt += 1
	print(cnt, m)


a = int(input())
for i in range(a):
	b = int(input())
	li = []
	if b == 2:
		print(2, 1)
	elif b == 3:
		print(3, 2)
	elif b == 4:
		print(4, 2)
	else:
		for t in range(b + 1):
			if b * t + 1 - 2 ** t < 0:
				li.append(t - 1)
				break
		for o in range(b + 1):
			if b <= 2 ** o:
				li.append(o)
				break
		print(*li)


li = [1]
for i in range(1, 50):
	li.append(li[-1] * 2)
for i in range(int(input())):
	no = int(input())
	ma1 = 0
	ma2 = 0
	p = 0
	j = 0
	maxd = 0
	while True:
		if p < 0:
			break
		else:
			p += no - li[j]
		if no > li[j]:
			maxd = j
		ma1 += no
		ma2 += li[j]
		j += 1
	print(j - 1, maxd + 1)


t = int(input())
for _ in range(t):
	a = int(input())
	profit = []
	i = 1
	value = 0
	while True:
		value += a - 2 ** (i - 1)
		if value >= 0:
			profit.append(value)
		else:
			break
		i += 1
	print('{} {}'.format(len(profit), profit.index(max(profit)) + 1))


import math
t = int(input())
for _ in range(t):
	a = int(input())
	ans = math.log(a / math.log(2), 2)
	temp = int(ans)
	d2 = temp
	if 2 ** temp < a:
		d2 = temp + 1
	i = d2
	while 2 ** (i + 1) - 1 < a * (i + 1):
		i = i + 1
	print(i, d2)
	pass


def two(x, i):
	if 2 ** i >= x:
		return i
	else:
		i += 1
		return two(x, i)
t = int(input(''))
for _ in range(t):
	a = int(input(''))
	d2 = two(a, 0)
	for i in range(d2, a + 1):
		if a * i > 2 ** i - 1:
			pass
		else:
			d1 = i - 1
			break
	print(d1, d2)


t = int(input())
for t in range(t):
	a = int(input())
	m = 0
	d1 = 0
	d2 = 1
	while 2 ** d1 < a:
		d1 += 1
	while 2 ** d2 - 1 < d2 * a:
		d2 += 1
	print(str(d2 - 1) + ' ' + str(d1))