#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
int frequency, day, i;
char carrot[10000] = {"\0"};
int x, y, z, w, n, m;
scanf("%d",&frequency);
while(frequency)
{
int flag = 0, t = 0;
scanf("%d %d %d %d %d %d",&x, &y, &z, &w, &n, &m);
fgets(carrot, sizeof(carrot), stdin);
day = strlen(carrot);
for(i = 0;i < day;i += 2)
{
if(flag > 0)
m -= n * t;
if(m <= 0)
break;
switch(carrot[i])
{
case '1':
m += x;
break;
case '2':
m += y;
break;
case '3':
m -= z;
break;
case '4':
m -= w;
flag ++;
t += 1;
break;
}
if(m <= 0)
break;
}
if(m <= 0)
printf("bye~Rabbit\n");
else
printf("%dg\n",m);
frequency --;
}
return 0;
}