URI Online Judge | 1627

Last Hit

By Cristhian Bonilha, UTFPR BR Brazil

Timelimit: 1

Andre and Beto are playing a computer game that rewards the players in a very particular way: only the one that gives the last hit to defeat a monster will get all the gold that the monster leave behind. This implies that, although others players may have helped to defeat the monster, only the one who gives the last hit will be rewarded.

Andre is intrigued with this system, and asked your help. Given the number of life points of the monster, the damage that Andre and Beto can cause, and the lead time necessary between two consecutive attacks, find out who will give the last hit on the monster, defeating it and getting the reward.

At the beginning both Andre and Beto will attack, dealing At and Bt damage points, respectively. After each attack, both Andre and Beto have to wait exactly Ad and Bd seconds, respectively, before they can attack again. Whenever Andre and Beto can attack at the same time (as in the beginning), Andre has the priority and attacks first. A monster is defeated when its life points come to less or equal to zero.


The first line contains an integer T, indicating the number of test cases to follow.

Each test case starts with four integers At, Ad, Bt and Bd (1 ≤ At, Ad, Bt, Bd ≤ 100), indicating the attack damage and the lead time between two consecutive attacks of Andre and Beto, respectively.

Following there will be an integer H (1 ≤ H ≤ 10000), indicating the number of life points of the monster.


For each test case print one line containing one name, this being “Andre” if he's the last one to hit the monster, or “Beto” otherwise.

Sample Input Sample Output

5 3 5 3
5 3 5 3
5 3 10 7