Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0029 - TIMEBOMB

   You and your teammates from the anti-bomb squad of the local police have been called to defuse a bomb found in the only pub in town. Fearing the tragic con- sequences this might produce, you go to the scene as quickly as possible. After some research, you learn that the bad guys have created a tricky way to allow them to defuse the bomb at will. You find a remote control with a button that you can take to a safe place. You also find that it is possible to connect to the bomb through a wireless connection and retrieve an ASCII represen- tation of a code every 2 seconds. The bomb then gets defused if the button is pressed when the code is a num- ber divisible by 6. But you have to be careful. If you press the button when the ASCII representation of the code is not a number divisible by 6 or has an invalid representation for any digit, the bomb will explode instead. You have to rely on your programming skills to write a program able to tell you if it is safe to press the button, before it blows out the pub (and the beer).

Input

   The input consists of an ASCII representation of a code. This code has between 2 and 8 digits. Each digit is represented by 5 rows and 3 columns of characters, which can be either a space or a star character ’*’. No other type of character (except for the new line character) will ever appear in the input. There is also one column of spaces (and only spaces) to separate each digit. After the last digit you will find a column of new line characters. Note that although every digit will always be of size 5 × 3, there is no guarantee it will represent a valid digit between 0 and 9 inclusive. The valid 5 × 3 representations for each digit are given below in Figure F.1.

   Figure F.1: The hash ’#’ characters on the top are there only to mark the 3 columns used for a digit and are not part of the digits’ representation.

   The code can have leading zeros, hence an ASCII representation of, for example, 00000076 represents the number 76. You may also safely assume that every valid code will correspond to a strictly positive number.

Output

   Print one line with “BEER!!”  if it is safe to press the button and defuse the bomb, and “BOOM!!” otherwise.

Examples

stdin

stdout

1

BEER!!

2

BOOM!!


Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2013-12-15
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.Nordic (NCPC) 2013.F

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.