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: interview

Starter code:

Solutions:
# cook your dish here
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)
  


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)


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)

# cook your dish here - pyt3
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

# cook your dish here
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
# one extra day gets counted after profit becomes negative
 print(d2-1,d1)

# cook your dish here
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)

# cook your dish here
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

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=' ')
 

T = int(input())

for i in range(T):
 a = int(input())
 
 # d2 = n such that 2^n is just greater than a.  
 # d1 = max days so that profit is > 0.
 
 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)

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])


# cook your dish here
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)
  


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)

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)

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)
 # print(m)
 t-=1

# cook your dish here
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

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

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)

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
  # print('ff')
  while(g>0):
   # print('hjh')
   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

# cook your dish here
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) 

# cook your dish here
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)

# cook your dish here
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

# cook your dish here
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())
 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)

# cook your dish here
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