Morse code represents each character as a variable-length sequence of dots (.) and dashes (-). In a real message, characters are separated by short pauses. The table below gives the Morse sequence for each character.
| Letter | Code | Letter | Code | Letter | Code | Letter | Code |
|---|---|---|---|---|---|---|---|
| A | .- | H | .... | O | --- | V | ...- |
| B | -... | I | .. | P | .--. | W | .-- |
| C | -.-. | J | .--- | Q | --.- | X | -..- |
| D | -.. | K | -.- | R | .-. | Y | -.-- |
| E | . | L | .-.. | S | ... | Z | --.. |
| F | ..-. | M | -- | T | - | ||
| G | --. | N | -. | U | ..- |
In standard Morse code, four dot-dash combinations are unassigned. For this problem we assign those four combinations as follows (these are not the assignments used in real Morse code).
| Character | Code |
|---|---|
underscore (_) | ..-- |
period (.) | ---. |
comma (,) | .-.- |
question mark (?) | ---- |
For example, the message ACM_GREATER_NY_REGION is encoded as:
.- -.-. -- ..-- --. .-. . .- - . .-. ..-- -. -.-- ..-- .-. . --. .. --- -.
M.E. Ohaver proposed an encryption scheme based on mutilating Morse code. Because Morse code is variable-length and not prefix-free, pauses between letters are normally required; this scheme replaces those pauses with a string of numbers giving the length of each character's code. For example, .--.-.-- on its own could be ACM, ANK, or several other possibilities, but adding the length information .--.-.--242 makes it unambiguous.
Ohaver's scheme has three steps, and encryption and decryption use the same steps.
For example, converting the message AKADTOF_IBOETATUK_IJN to Morse code with a length string yields:
.--.-.--..----..-...--..-...---.-.--..--.-..--...----.232313442431121334242
Reversing the numbers and decoding then yields the original message ACM_GREATER_NY_REGION.
Implement Ohaver's algorithm.
The first line of input is an integer $n$, the number of messages. Each of the following $n$ lines contains one message. Every message uses only the twenty-six uppercase letters, underscores (_), commas (,), periods (.), and question marks (?), and is at most 100 characters long.
For each message, print the message number (starting at 1) beginning in column one, then a colon (:), a space, and then the decoded message. Follow the output format exactly.
As presented, this scheme is only trivially secure and offers no security at all once the algorithm is known to an attacker. The string of numbers that decides where the pauses go is the key, but here that information is encoded in, and easily recovered from, the ciphertext. Even if some other method were chosen to scramble the length information, secrecy of the algorithm would still be the real key. Variants of Ohaver's technique exist whose security does not rely on keeping the algorithm secret.