Pied Piper is a startup company trying to build a new Internet called Pipernet. Currently, they have $A$ users and they gain $X$ users everyday. There is also another company called Hooli, which has currently $B$ users and gains $Y$ users everyday.
Whichever company reaches $Z$ users first takes over Pipernet. In case both companies reach $Z$ users on the same day, Hooli takes over.
Hooli is a very evil company (like E-Corp in Mr. Robot or Innovative Online Industries in Ready Player One). Therefore, many people are trying to help Pied Piper gain some users.
Pied Piper has $N$ supporters with contribution values $C_1, C_2, \ldots, C_N$. For each valid $i$, when the $i$-th supporter contributes, Pied Piper gains $C_i$ users instantly. After contributing, the contribution value of the supporter is halved, i.e. $C_i$ changes to $\left\lfloor C_i / 2 \right\rfloor$. Each supporter may contribute any number of times, including zero. Supporters may contribute at any time until one of the companies takes over Pipernet, even during the current day.
Find the minimum number of times supporters must contribute (the minimum total number of contributions) so that Pied Piper gains control of Pipernet.

-----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 line of each test case contains six space-separated integers $N$, $A$, $B$, $X$, $Y$ and $Z$.
- The second line contains $N$ space-separated integers $C_1, C_2, \ldots, C_N$ — the initial contribution values.

-----Output-----
For each test case, if Hooli will always gain control of Pipernet, print a single line containing the string "RIP" (without quotes). Otherwise, print a single line containing one integer — the minimum number of times supporters must contribute.

-----Constraints-----
- $1 \le T \le 10$
- $1 \le N \le 10^5$
- $1 \le A, B, X, Y, Z \le 10^9$
- $A, B < Z$
- $0 \le C_i \le 10^9$ for each valid $i$

-----Example Input-----
3
3 10 15 5 10 100
12 15 18
3 10 15 5 10 100
5 5 10
4 40 80 30 30 100
100 100 100 100

-----Example Output-----
4
RIP
1

-----Explanation-----
Example case 1: After $8$ days, Pied Piper will have $50$ users and Hooli will have $95$ users. Then, if each supporter contributes once, Pied Piper will also have $95$ users. After that, they still need $5$ more users, so supporter $3$ can contribute again, with $18/2 = 9$ more users. So the answer will be $4$.
Example case 2: There is no way to beat Hooli.

Starter code:

Solutions:
# cook your dish here
import heapq as hq
from math import floor
for _ in range(int(input())):
 n,a,b,x,y,z=map(int,input().split())
 arr=[-int(i) for i in input().split()]
 days=((z-b-1)//y)
 ans=0
 hq.heapify(arr)
 curr=a+days*x
 while curr<z :
  u=hq.heappop(arr)
  u=-u
  if u==0 :
   break
  else:
   curr+=u
   ans+=1
   hq.heappush(arr,-(u//2))
 if curr>=z:
  print(ans)
 else:
  print("RIP")

# cook your dish here
import heapq as hq
from math import floor
for _ in range(int(input())):
 n,a,b,x,y,z=list(map(int,input().split()))
 arr=[-int(i) for i in input().split()]
 days=((z-b-1)//y)
 

 ans=0

 hq.heapify(arr)
 curr=a+days*x

 while curr<z :

  u=hq.heappop(arr)
  u=-u
  if u==0 :
   break
  else:
   curr+=u
   ans+=1
   hq.heappush(arr,-(u//2))

 if curr>=z:

  print(ans)
 else:
  print("RIP")







# cook your dish here
import heapq as hq
from math import floor
for _ in range(int(input())):
 n,a,b,x,y,z=list(map(int,input().split()))
 arr=[-int(i) for i in input().split()]
 days=floor((z-b-1)/y)
 

 ans=0

 hq.heapify(arr)
 curr=a+days*x

 while curr<z :

  u=hq.heappop(arr)
  u=-u
  if u==0 :
   break
  else:
   curr+=u
   ans+=1
   hq.heappush(arr,-(u//2))

 if curr>=z:

  print(ans)
 else:
  print("RIP")







# cook your dish here
import heapq as hq
from math import floor
for _ in range(int(input())):
 n,a,b,x,y,z=list(map(int,input().split()))
 arr=[-int(i) for i in input().split()]
 days=floor((z-b)/y)
 if b+y*days==z:
  z+=1


 ans=0

 hq.heapify(arr)
 curr=a+days*x

 while curr<z :

  u=hq.heappop(arr)
  u=-u
  if u==0 :
   break
  else:
   curr+=u
   ans+=1
   hq.heappush(arr,-(u//2))

 if curr>=z:

  print(ans)
 else:
  print("RIP")







# cook your dish here
import heapq
from math import ceil, floor
for _ in range(int(input())):
 n, a, b, x, y, z = map(int,input().split())
 s = [-int(i) for i in input().split()]
 days = floor((z-b)/y)
 current = a+days*x
 if b+days*y==z:
  z+=1
 count = 0
 heapq.heapify(s)

 while current<z:
  ret = heapq.heappop(s)
  ret = -ret

  if ret == 0:
   break
  else:
   current+=ret
   heapq.heappush(s,-(ret//2))
   #heapq.heapify(s)
  count+=1
 print(count) if current>=z else print("RIP")

# cook your dish here
import heapq
from math import ceil, floor
for _ in range(int(input())):
 n, a, b, x, y, z = map(int,input().split())
 s = [-int(i) for i in input().split()]
 days = floor((z-b)/y)
 current = a+days*x
 if b+days*y==z:
  z+=1
 count = 0
 heapq.heapify(s)

 while current<z:
  ret = heapq.heappop(s)
  ret = -ret

  if ret == 0:
   break
  else:
   current+=ret
   heapq.heappush(s,-(ret//2))
   #heapq.heapify(s)
  count+=1
 print(count) if current>=z else print("RIP")

# cook your dish here
import heapq
import math
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= list(map(int,input().split()))
 t=math.ceil((z-b)/y)
 sumy= a+ x*(t-1) 
 if (sum(cntrbtns)*2 +sumy) < z:
  print("RIP")
  continue
 c=0
 for i in range(n):
  cntrbtns[i]= - cntrbtns[i]
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sumy>=z:
   print(c)
   break
  ele=heapq.heappushpop(cntrbtns,math.ceil(ele/2))
  if ele==0:
   print("RIP")
   break
  sumy -=ele 
  c+=1 
  



# cook your dish here
import heapq
import math
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= list(map(int,input().split()))
 t=math.ceil((z-b)/y)
 sumy= a+ x*(t-1) 
 if (sum(cntrbtns)*2 +sumy) < z:
  print("RIP")
  continue
 c=0
 for i in range(n):
  cntrbtns[i]= - cntrbtns[i]
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sumy>=z:
   print(c)
   break
  ele=heapq.heappushpop(cntrbtns,math.ceil(ele/2))
  if ele==0:
   print("RIP")
   break
  sumy -=ele 
  c+=1 
  



# cook your dish here
import heapq
from math import ceil
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= [-(int(x)) for x in input().split()]
 
 if b>=z :
  print("RIP")
  continue
 sum= a+ x*(ceil((z-b)/y)-1) 
 c=0
 heapq.heapify(cntrbtns)
 ele=0
 while sum<z and any(cntrbtns):
  ele=-heapq.heappop(cntrbtns)
  sum+=ele
  heapq.heappush(cntrbtns,-(ele>>1))
  c+=1 
 print(["RIP",c][sum>=z])


# cook your dish here
import heapq
from math import ceil
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= [-(int(x)) for x in input().split()]
 
 if b>=z :
  print("RIP")
  continue
 sum= a+ x*(ceil((z-b)/y)-1) 
 c=0
 heapq.heapify(cntrbtns)
 ele=0
 while sum<z and any(cntrbtns):
  ele=-heapq.heappushpop(cntrbtns,-(ele>>1))
  sum+=ele 
  c+=1 
 print(["RIP",c][sum>=z])


# cook your dish here
import heapq
from math import ceil
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= [-(int(x)) for x in input().split()]
 
 if b>=z :
  print("RIP")
  continue
 sum= a+ x*(ceil((z-b)/y)-1) 
 c=0
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sum>=z:
   print(c)
   break
  ele=-ele
  ele=heapq.heappushpop(cntrbtns,-(ele>>1))
  if ele==0:
   print("RIP")
   break
  sum-=ele 
  c+=1 
  


# cook your dish here
import heapq
from math import ceil
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= [-(int(x)) for x in input().split()]
 
 if b>=z :
  print("RIP")
  continue
 t=ceil((z-b)/y)
 sum= a+ x*(t-1) 
 c=0
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sum>=z:
   print(c)
   break
  ele=-ele
  ele=heapq.heappushpop(cntrbtns,-(ele>>1))
  if ele==0:
   print("RIP")
   break
  sum-=ele 
  c+=1 
  


import heapq
from math import ceil
for _ in range(int(input())):
 n,a,b,x,y,z =[int(i) for i in input().split()]
 A=[-int(i) for i in input().split()]
 heapq.heapify(A)
 days=ceil((z-b)/y)
 pig=z-a
 if(ceil((pig+2*sum(A))/x)>=days):
  print("RIP")
 else:
  ans=0
  while(ceil(pig/x)>=days and any(A)):
   use=-heapq.heappop(A)
   pig-=use
   heapq.heappush(A,-(use>> 1))
   ans+=1
  print(["RIP",ans][ceil(pig/x)<days])


# cook your dish here
import heapq
import math
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= [-(int(x)) for x in input().split()]
 
 if b>=z :
  print("RIP")
  continue
 t=math.ceil((z-b)/y)
 sum= a+ x*(t-1) 
 c=0
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sum>=z:
   print(c)
   break
  ele=-ele
  ele=heapq.heappushpop(cntrbtns,-(ele>>1))
  if ele==0:
   print("RIP")
   break
  sum-=ele 
  c+=1 
  


from collections import deque
import math
def solve(nums, d,z):
 q1 = deque(sorted(nums, reverse=True))
 q2 = deque()
 c=0
 if d>=z:
  return c
 while True:
  if len(q1)==0 and len(q2)==0:
   break
  if not q2 or q1[0] > q2[0]:
   ele = q1.popleft()
   c+=1
   d+=ele
   if d>=z:
    return c
   ele = ele // 2
   if ele>=1:
    q2.append(ele)
  else:
   ele = q2.popleft()
   c+=1
   d+=ele
   if d>=z:
    return c
   ele = ele // 2
   if ele>=2:
    q2.append(ele)
  
  if not q1:
   q1, q2 = q2, q1
 if d>=z:
  return c
 return 'RIP'
  
 
t=int(input())
for _ in range(t):
 n,a,b,x,y,z=list(map(int,input().split()))
 nums = list(map(int, input().split()))
 queries = set([])
 c=z-b
 c=math.ceil(c/y)-1
 d=a+x*c
 if d>=z:
  print(0)
 else:
  
 
  print(solve(nums,d,z))



# cook your dish here
from collections import deque

import math
def solve(nums, d,z):
 q1 = deque(sorted(nums, reverse=True))
 q2 = deque()
 c=0
 if d>=z:
  return c
 while True:
  if len(q1)==0 and len(q2)==0:
   break
  if not q2 or q1[0] > q2[0]:
   ele = q1.popleft()
   c+=1
   d+=ele
   if d>=z:
    return c
   ele = ele // 2
   if ele>=1:
    q2.append(ele)
  else:
   ele = q2.popleft()
   c+=1
   d+=ele
   if d>=z:
    return c
   ele = ele // 2
   if ele>=2:
    q2.append(ele)
  
  if not q1:
   q1, q2 = q2, q1
 if d>=z:
  return c
 return 'RIP'
  
 
t=int(input())
for _ in range(t):
 n,a,b,x,y,z=list(map(int,input().split()))
 nums = list(map(int, input().split()))
 queries = set([])
 c=z-b
 c=math.ceil(c/y)-1
 d=a+x*c
 if d>=z:
  print(0)
 else:
  
 
  print(solve(nums,d,z))



# cook your dish here
import heapq
import math
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= [-(int(x)) for x in input().split()]
 
 if b>=z :
  print("RIP")
  continue
 t=math.ceil((z-b)/y)
 sum= a+ x*(t-1) 
 c=0
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sum>=z:
   print(c)
   break
  ele=-ele
  ele=heapq.heappushpop(cntrbtns,-(ele//2))
  if ele==0:
   print("RIP")
   break
  sum-=ele 
  c+=1 
  


# cook your dish here
import heapq
import math
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= list(map(int,input().split()))
 
 if b>=z :
  print("RIP")
  continue
 t=math.ceil((z-b)/y)
 sum= a+ x*(t-1) 
 c=0
 for i in range(n):
  cntrbtns[i]= - cntrbtns[i]
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sum>=z:
   print(c)
   break
  ele=-ele
  ele=heapq.heappushpop(cntrbtns,-(ele//2))
  if ele==0:
   print("RIP")
   break
  sum-=ele 
  c+=1 
  


# cook your dish here
import heapq
import math
for i in range(int(input())):
 n,a,b,x,y,z = list(map(int,input().split()))
 cntrbtns= list(map(int,input().split()))
 
 if b>=z :
  print("RIP")
  continue
 t=math.ceil((z-b)/y)
 sum= a+ x*(t-1) 
 c=0
 for i in range(n):
  cntrbtns[i]= - cntrbtns[i]
 heapq.heapify(cntrbtns)
 ele=0
 while True:
  if sum>=z:
   print(c)
   break
  ele=heapq.heappushpop(cntrbtns,math.ceil(ele/2))
  if ele==0:
   print("RIP")
   break
  sum-=ele 
  c+=1 
  


# cook your dish here
import heapq
from math import ceil

t= int(input())
for k in range(t):
 n, a, b, x, y, z = list(map(int,input().split()))
 c = list(map(int,input().split()))
 cont = [ -int(x) for x in c]
 
 days = int((z-b) / y )
 
 p_user = days * x + a
 
 need = z - p_user
 flag = 0
 
 heapq.heapify(cont) 
 count = 0
 if ceil(((z-a) - (2*sum(c)))/x) >= days + 1:
  print("RIP")
 
 
 elif p_user > z:
  print(0)
 else:
  while( p_user < z):
   
   key = heapq.heappop(cont)
   if key ==0:
    flag = 1 
    break
   count += 1
   p_user += -key
   #print(need,key,cont)
   heapq.heappush(cont,int(key/2))
   
  if flag == 0:
   print(count)
  else :
   print("RIP")
   
  
  
  
  
  
  


#

import heapq
from math import ceil

for _ in range(int(input())):
 N, A, B, X, Y, Z = map(int, input().split())
 C = list(map(int, input().split()))
 heap = [-contrib for contrib in C]
 heapq.heapify(heap)
 
 hooli_days = ceil((Z-B)/Y)
 piper_init_gap = Z - A
 
 if ceil((piper_init_gap-2*sum(C))/X) >= hooli_days:
  print('RIP')
 else:
  num_contribs = 0
  while ceil(piper_init_gap/X) >= hooli_days and any(heap):
   contrib = -heapq.heappop(heap)
   piper_init_gap -= contrib
   heapq.heappush(heap, -(contrib >> 1))
   num_contribs += 1
  if ceil(piper_init_gap/X) < hooli_days:
   print(num_contribs)
  else:
   print('RIP')

import heapq
from math import ceil


for _ in range(int(input())):
 n, a, b, x, y, z = list(map(int, input().split()))
 c = [-int(i) for i in input().split()]
 heapq.heapify(c)
 days = ceil((z - b) / y)
 pig = z-a
 if ceil((pig + 2 * sum(c)) / x) >= days:
  print("RIP")
 else:
  ans = 0
  while ceil(pig / x) >= days and any(c):
   use = -heapq.heappop(c)
   pig -= use
   heapq.heappush(c, -(use >> 1))
   ans += 1
  if ceil(pig / x) >= days:
   print("RIP")
  else:
   print(ans)


import heapq as heap

for t in range(int(input())):
 n, a, b, x, y, z = map(int,input().split( ))
 h = list(map(int,input().split( )))
 for i in range(n):
  h[i] *= -1
 heap.heapify(h)
 extra = (z - b - 1) // y
 a += x * extra
 b += y * extra
 ans = 0
 while a < z and h:
  maximum = -1 * heap.heappop(h)
  a += maximum
  ans += 1
  maximum //= 2
  if maximum:
   heap.heappush(h,-1 * maximum)
 if a < z:
  print("RIP")
 else:
  print(ans)