#K51957. Morse Code Converter

    ID: 29202 Type: Default 1000ms 256MiB

Morse Code Converter

Morse Code Converter

You are given a conversion task between text and Morse code. In the first mode, the program converts plain text to Morse code. In the second mode, it converts Morse code back to text.

The first line of input is a mode indicator: "T2M" for text-to-Morse conversion and "M2T" for Morse-to-text conversion. The second line contains the string to be converted. In text-to-Morse conversion, only letters (A-Z), digits (0-9) and spaces are considered; any other characters are ignored. Letters are converted by mapping each character to its corresponding Morse code sequence, with each Morse code letter separated by a space and words separated by a slash ('/'). In Morse-to-text conversion, words are separated by a slash ('/') and letters by spaces. Your task is to implement the correct conversion according to the mode provided.

Note: All letters should be handled in uppercase.

inputFormat

The input consists of two lines. The first line is a mode indicator which is either "T2M" or "M2T". The second line is the string that needs to be converted.

outputFormat

Output a single line containing the converted string. In "T2M" mode, output the Morse code representation; in "M2T" mode, output the corresponding text.

## sample
T2M
HELLO WORLD
.... . .-.. .-.. --- / .-- --- .-. .-.. -..