//
// File: code.cc
// Author: cteam019
//
// Created on October 19, 2013, 10:42 AM
//
#include <stdlib.h>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
char g_Buffer[1024];
//const char* g_Buffer = "FENDSVTSLHW.EDATS,EULAY";
typedef std::map<char, std::string> c2smap;
typedef c2smap::iterator c2siter;
c2smap g_Table;
typedef std::map<std::string, char> s2cmap;
typedef s2cmap::iterator s2citer;
s2cmap g_ToLetter;
std::string g_Decoded;
std::vector<int> g_Lenghts;
std::string g_Morse;
typedef std::string::iterator StrIter;
void do_stuff(){
g_Buffer[0] = 0;
gets(g_Buffer);
if ( strlen(g_Buffer) == 0 ) exit(EXIT_SUCCESS);
g_Lenghts.clear();
g_Morse.clear();
g_Decoded.clear();
int i = 0;
while(g_Buffer[i] != 0) {
std::string& rep = g_Table[g_Buffer[i]];
g_Morse.append(rep);
g_Lenghts.push_back(rep.size());
++i;
}
//std::reverse(g_Lenghts.begin(), g_Lenghts.end());
int pos = 0;
while (!g_Lenghts.empty()) {
int len = g_Lenghts.back();
g_Lenghts.pop_back();
std::string bit = g_Morse.substr(pos, len);
g_Decoded += g_ToLetter[bit];
pos += len;
}
puts(g_Decoded.c_str());
}
void init(){
g_Morse.reserve(10000);
g_Table['A'] = ".-";//A
g_Table['B'] = "-...";//A
g_Table['C'] = "-.-.";//A
g_Table['D'] = "-..";//A
g_Table['E'] = ".";//A
g_Table['F'] = "..-.";//A
g_Table['G'] = "--.";//A
g_Table['H'] = "....";//A
g_Table['I'] = "..";//A
g_Table['J'] = ".---";//A
g_Table['K'] = "-.-";//A
g_Table['L'] = ".-..";//A
g_Table['M'] = "--";//A
g_Table['N'] = "-.";//A
g_Table['O'] = "---";//A
g_Table['P'] = ".--.";//A
g_Table['Q'] = "--.-";//A
g_Table['R'] = ".-.";//A
g_Table['S'] = "...";//A
g_Table['T'] = "-";//A
g_Table['U'] = "..-";//A
g_Table['V'] = "...-";//A
g_Table['W'] = ".--";//A
g_Table['X'] = "-..-";//A
g_Table['Y'] = "-.--";//A
g_Table['Z'] = "--..";//A
g_Table['_'] = "..--";//A
g_Table[','] = ".-.-";//A
g_Table['.'] = "---.";//A
g_Table['?'] = "----";//A
for ( c2siter it = g_Table.begin(), end = g_Table.end(); it != end; ++it )
g_ToLetter[it->second] = it->first;
}
//
//
//
int main(int argc, char** argv) {
init();
while(!feof(stdin)){
do_stuff();
}
return (EXIT_SUCCESS);
}