Skip to content

UKSPC Practice Problems » Golf

The game of golf is mysterious in many ways. First, it is hard to understand what is enjoyable about whacking a ball around a field for hours. Second, it is difficult to see how it's possible for people that have all the time in the world in which to count the number of strokes they make, seem unable to remember some of them, as is shown by the low scores turned in at the end of the round by many club players. Third, instead of counting in numbers, they use terms like 'par', 'birdie' (1 below par) and 'bogey' (1 over par), and in rare cases 'hole-in-one', 'eagle' (2 below par), 'double eagle' (3 below par) and 'double bogey' (2 over par). Although it is possible to get worse than a double bogey, and they have names for those too, we'll just assume that most people when getting more than a double bogey will forget the extra strokes and write down 'double bogey'.

John has just joined the golf club and is new to the names of scores and has truthfully filled in his score card (including the 7 he scored on the par-4 hole 9, after his ball went swimming), and needs to be explained how each of his scores is called (as well as that he should change that triple-bogey 7 to a double-bogey 6).

Your job as John's caddy is to write a program that, given the par for a hole and the number of strokes John wrote down, tells him what the score is called (and on the way forget any strokes worse than a double-bogey). Please make sure that if John gets a hole-in-one, it is named that, and nothing else.

Input Specification

The first line of input specifies the number N of holes John played. The next lines contain two integers P and S, separated by a single space. P is the par for the hole (P is either 3, 4 or 5) and S is the score John took (any positive integer less than 20).

Output Specification

For each hole, print on a single line the applicable text, as specified by the above explanation:

Example Input

5 3
3 5
4 7
5 5

Example Output

Double bogey.
Double bogey.