Multiple in Table Tennis
Basic Accuracy: 39.57% Submissions: 965 Points: 1

Ram and Rohan are best friends. Suddenly they got into the idea of becoming table tennis player.To excel in this sport, they decided to play several matches one by one and try to win the matches. After some training, they are now prepared for the matches. Coach of both the players have given them their respective strengths, m and n. Now they will win the matches only if their opponent's strength are in the integral multiple of their strengths. Ram and Rohan plays turn one by one and Ram always plays the first.  Also if one opponent is defeated by any one of  Ram or Rohan, then that opponent will not be able to fight again. Find out who is the better player among both of them.

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains 3 lines. The first line of each test case contains an integer k, denoting the number of opponents.The next line contains two space separated  integers i.e m and n which denotes the strength of Ram and Rohan respectively. Next line contains k separated integer denoting the strength of different opponent, ai.

Display the name of better player between Ram and Rohan who wins more matches. If both wins equal number of matches print "Both" without quotes.

1 <= T <= 26
1 <= k,m,n <= 105
1 <= ai <= 108

2 3
4 5 7 8 9 10 14
5 3
1 9 9 10 9 18

For first test case Ram will win with opponent having strength 4,8,10,14 while Rohan will win with only 9. So result is Ram

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.