A Game
Practice
3.9 (191 votes)
Mathematics
Easy Medium
Problem
39% Success 3523 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Two sweet dogs, Bernard and Havanese, play the following game.
There are P sticks, each of exactly Q meters in length. The dogs move in turns. For each move a dog chooses a stick and splits it into two or more equal parts each having integer length greater than or equal to S meters. Each resulting part is also a stick. The dog that can't make a move loses. Thus, the other dog wins.
Bernard makes the first move. Now you have to determine the winner if players play in the optimal way.

Input :
First line of Input contains number of test cases T. Each test case contains three integers P, Q and S.

Output :
For each test case print "Bernard", if Bernard wins, or "Havanese", if Havanese wins. You should print everything without the quotes.

Constraint:
1 ≤ T ≤ 10
1 ≤ P,Q,S ≤ 109

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Easy-Medium
Points:20
6 votes
Tags:
MathematicsOpenApprovedEasy
Points:30
40 votes
Tags:
ApprovedData StructuresMathMediumStacks