Go Back
Who Will Break The Handi? (100)

Amit, Bipin and Chetan are enjoying themselves in the festive mood of Janmashtami. They decide that they will participate in the Dahi Handi event organized in their city. However, only one of them can climb atop and break the ‘Handi’. Chetan is afraid of heights and doesn’t wish to climb atop. To help decide who should be the one to break the Handi, Chetan suggests a game of penalty shoot-out. Amit and Bipin will be the strikers and Chetan will be the goalkeeper.
Energy levels of Amit, Bipin and Chetan are denoted by A, B and C respectively. For every goal scored by Amit and Bipin, their energy decreases by 1. For every goal saved by Chetan, his energy decreases by 1. Amit and Bipin can score goals only if Chetan’s energy is a factor of their energy, otherwise not. The game ends when Chetan’s energy reaches 1.
Assume that same player can repeatedly try for goals. Amit being the junior player is always favored for the penalty kick in case if both of them can score goals at the same time. The player who scores the most goals wins the game and will climb atop to break the Handi.
Find who wins the game.


The first line of input contains an input T denoting the number of Test cases.
Each test case contains 3 space-separated integers on the same line denoting the initial energy levels A, B & C respectively.


For each Test Case, output who scored the most goals on a single line. Output “Draw” in case of a draw (Without the quotes).


1<=A, B, C<=10^5

Copy Input

4 9 5
13 10 7


Case 1:
Energy of Chetan is 5, which is not a factor of either 4 or 9. Thus Chetan saved the goal and his energy decreases by 1. Now, Chetan’s energy is 4, which is a factor of Amit’s energy 4. Amit scores a goal and his energy decreases by 1. This goes on until Chetan’s energy reaches 1. At this point, Amit has scored 3 goals and Bipin has scored 2 goals. Amit has won and we output A.

September Queue
36 hour long contest

01:40 PM: Check your submission to see details about CE or RTE
12:28 PM: In Problem D, all the numbers are in single line for each test
Tips and Tricks for Python: Visit Here
Tips and Tricks for C++: Visit Here
Tips and Tricks for Java: Visit Here

Problem Tags

Supported by our Coding Partner