N=int(input())
for i in range(N):
weight_lst=input().split(" ")
weight=int(weight_lst[5])
day_lst=input().split(" ")
health=0
life=True
if day_lst==[]:
print(weight_lst[5])
continue
for j in day_lst:
if j=="":
break
weight-=(health*int(weight_lst[4]))
if j =="0":
continue
elif j=="1":
weight+=int(weight_lst[0])
elif j=="2":
weight+=int(weight_lst[1])
elif j=="3":
weight-=int(weight_lst[2])
elif j=="4":
weight-=int(weight_lst[3])
health+=1
if weight<=0:
life=False
break
if life:
print(str(weight)+"g")
else:
print("bye~Rabbit")