<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\problemname{Timebomb}

\illustration{.4}{bomb}{Photo by \href{http://2.bp.blogspot.com/_pXlgfIyoeR0/TOOAykjGuAI/AAAAAAAABhA/r2BE16F7p8Y/s400/bomb\%2Bdefuse5.jpg}{Chris
Welch}}

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 consequences 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
representation of a code every 2 seconds. The bomb then gets defused if the button is
pressed when the code is a number 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).

\section*{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 '\texttt{*}'. 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\times 3$,
there is no guarantee it will represent a valid digit between 0 and 9 inclusive. The valid
$5\times 3$ representations for each digit are given below in Figure~\ref{fig:digits}.

\begin{figure}[h]
  \centering
  \begin{minipage}{0.5\textwidth}
\begin{verbatim}
### ### ### ### ### ### ### ### ### ###
***   * *** *** * * *** *** *** *** ***
* *   *   *   * * * *   *     * * * * *
* *   * *** *** *** *** ***   * *** ***
* *   * *     *   *   * * *   * * *   *
***   * *** ***   * *** ***   * *** ***
\end{verbatim}
  \end{minipage}
  \caption{The hash '{\tt \#}' characters on the top are there only to mark the 3 columns used for
    a digit and are not part of the digits' representation.}
  \label{fig:digits}
\end{figure}

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.

\section*{Output}

Print one line with ``{\tt BEER!!}'' if it is safe to press the
button and defuse the bomb, and ``{\tt BOOM!!}'' otherwise.
</pre></body></html>