#P1200. Comet and Group Ride

    ID: 14102 Type: Default 1000ms 256MiB

Comet and Group Ride

Comet and Group Ride

This problem involves determining whether a particular group of supporters will be taken by a UFO following a comet. The UFO can only take one group at a time, so they have a clever way to decide which group gets taken. Each comet and each group is given a name consisting solely of uppercase letters (with at most 6 letters). These names are converted into a number by taking the product of the numerical values of their letters, where A is 1, B is 2, ..., and Z is 26. For example, the group name USACO is converted as:

\(21 \times 19 \times 1 \times 3 \times 15 = 17955\).

After obtaining the numbers for a comet name and a group name, compute each modulo 47. If the two remainders are equal, then output GO (which means the group will be taken by the UFO); otherwise, output STAY.

Note: The notation \(a \bmod b\) represents the remainder when a is divided by b. For instance, \(34 \bmod 10 = 4\).

inputFormat

The input consists of two lines. The first line contains the comet name and the second line contains the group name. Both names are strings of uppercase letters (with no spaces or punctuation) and are at most 6 characters long.

outputFormat

Output a single line containing either GO if the group’s number modulo 47 equals the comet’s number modulo 47, or STAY otherwise.

sample

COMETQ
HVNGAT
GO