import sys



CharToSign = {

    "A": "00000", "B": "00001", "C": "00010", "D": "00011",

    "E": "00100", "F": "00101", "G": "00110", "H": "00111",

    "I": "01000", "J": "01001", "K": "01010", "L": "01011",

    "M": "01100", "N": "01101", "O": "01110", "P": "01111",

    "Q": "10000", "R": "10001", "S": "10010", "T": "10011",

    "U": "10100", "V": "10101", "W": "10110", "X": "10111",

    "Y": "11000", "Z": "11001", " ": "11010", ".": "11011",

    ",": "11100", "-": "11101", "'": "11110", "?": "11111",

}

SignToChar = {

    "101": " ", "000000": "'", "000011": ",", "10010001": "-",

    "010001": ".", "000001": "?", "100101": "A", "10011010": "B",

    "0101": "C", "0001": "D", "110": "E", "01001": "F",

    "10011011": "G", "010000": "H", "0111": "I", "10011000": "J",

    "0110": "K", "00100": "L", "10011001": "M", "10011110": "N",

    "00101": "O", "111": "P", "10011111": "Q", "1000": "R",

    "00110": "S", "00111": "T", "10011100": "U", "10011101": "V",

    "000010": "W", "10010010": "X", "10010011": "Y", "10010000": "Z",

}



for line in sys.stdin:

    line = line[:-1]



    sign = []

    for char in line:

        convert = CharToSign[char]

        sign.append(convert)



    sign = "".join(sign)



    startIndex = 0

    endIndex = 3



    string = []



    length = len(sign)

    while endIndex <= length:



        part = sign[startIndex:endIndex]

        if part in SignToChar:

            convert = SignToChar[part]

            string.append(convert)

            startIndex = endIndex

            endIndex += 3

        else:

            endIndex += 1



    string = "".join(string)

    print(string)



import sys



CharToSign = {

    "A": "00000", "B": "00001", "C": "00010", "D": "00011",

    "E": "00100", "F": "00101", "G": "00110", "H": "00111",

    "I": "01000", "J": "01001", "K": "01010", "L": "01011",

    "M": "01100", "N": "01101", "O": "01110", "P": "01111",

    "Q": "10000", "R": "10001", "S": "10010", "T": "10011",

    "U": "10100", "V": "10101", "W": "10110", "X": "10111",

    "Y": "11000", "Z": "11001", " ": "11010", ".": "11011",

    ",": "11100", "-": "11101", "'": "11110", "?": "11111",

}

SignToChar = {

    "101": " ", "000000": "'", "000011": ",", "10010001": "-",

    "010001": ".", "000001": "?", "100101": "A", "10011010": "B",

    "0101": "C", "0001": "D", "110": "E", "01001": "F",

    "10011011": "G", "010000": "H", "0111": "I", "10011000": "J",

    "0110": "K", "00100": "L", "10011001": "M", "10011110": "N",

    "00101": "O", "111": "P", "10011111": "Q", "1000": "R",

    "00110": "S", "00111": "T", "10011100": "U", "10011101": "V",

    "000010": "W", "10010010": "X", "10010011": "Y", "10010000": "Z",

}



for line in sys.stdin:

    line = line[:-1]



    sign = ""

    for char in line:

        sign += CharToSign[char]



    string = ""

    part = ""



    for item in sign:

        part += item



        if part in SignToChar:

            string += SignToChar[part]

            part = ""



    print(string)



import sys

CharToSign = {
    "A": "00000",
    "B": "00001",
    "C": "00010",
    "D": "00011",
    "E": "00100",
    "F": "00101",
    "G": "00110",
    "H": "00111",
    "I": "01000",
    "J": "01001",
    "K": "01010",
    "L": "01011",
    "M": "01100",
    "N": "01101",
    "O": "01110",
    "P": "01111",
    "Q": "10000",
    "R": "10001",
    "S": "10010",
    "T": "10011",
    "U": "10100",
    "V": "10101",
    "W": "10110",
    "X": "10111",
    "Y": "11000",
    "Z": "11001",
    " ": "11010",
    ".": "11011",
    ",": "11100",
    "-": "11101",
    "'": "11110",
    "?": "11111",
}
SignToChar = {
    "101": " ",
    "000000": "'",
    "000011": ",",
    "10010001": "-",
    "010001": ".",
    "000001": "?",
    "100101": "A",
    "10011010": "B",
    "0101": "C",
    "0001": "D",
    "110": "E",
    "01001": "F",
    "10011011": "G",
    "010000": "H",
    "0111": "I",
    "10011000": "J",
    "0110": "K",
    "00100": "L",
    "10011001": "M",
    "10011110": "N",
    "00101": "O",
    "111": "P",
    "10011111": "Q",
    "1000": "R",
    "00110": "S",
    "00111": "T",
    "10011100": "U",
    "10011101": "V",
    "000010": "W",
    "10010010": "X",
    "10010011": "Y",
    "10010000": "Z",
}
for line in sys.stdin:
    line = line[:-1]
    sign = []
    for char in line:
        convert = CharToSign[char]
        sign.append(convert)
    sign = "".join(sign)
    startIndex = 0
    endIndex = 3
    string = []
    length = len(sign)
    while endIndex <= length:
        part = sign[startIndex:endIndex]
        if part in SignToChar:
            convert = SignToChar[part]
            string.append(convert)
            startIndex = endIndex
            endIndex += 3
        else:
            endIndex += 1
    string = "".join(string)
    print(string)

import sys

CharToSign = {
    "A": "00000",
    "B": "00001",
    "C": "00010",
    "D": "00011",
    "E": "00100",
    "F": "00101",
    "G": "00110",
    "H": "00111",
    "I": "01000",
    "J": "01001",
    "K": "01010",
    "L": "01011",
    "M": "01100",
    "N": "01101",
    "O": "01110",
    "P": "01111",
    "Q": "10000",
    "R": "10001",
    "S": "10010",
    "T": "10011",
    "U": "10100",
    "V": "10101",
    "W": "10110",
    "X": "10111",
    "Y": "11000",
    "Z": "11001",
    " ": "11010",
    ".": "11011",
    ",": "11100",
    "-": "11101",
    "'": "11110",
    "?": "11111",
}
SignToChar = {
    "101": " ",
    "000000": "'",
    "000011": ",",
    "10010001": "-",
    "010001": ".",
    "000001": "?",
    "100101": "A",
    "10011010": "B",
    "0101": "C",
    "0001": "D",
    "110": "E",
    "01001": "F",
    "10011011": "G",
    "010000": "H",
    "0111": "I",
    "10011000": "J",
    "0110": "K",
    "00100": "L",
    "10011001": "M",
    "10011110": "N",
    "00101": "O",
    "111": "P",
    "10011111": "Q",
    "1000": "R",
    "00110": "S",
    "00111": "T",
    "10011100": "U",
    "10011101": "V",
    "000010": "W",
    "10010010": "X",
    "10010011": "Y",
    "10010000": "Z",
}
for line in sys.stdin:
    line = line[:-1]
    sign = ""
    for char in line:
        sign += CharToSign[char]
    string = ""
    part = ""
    for item in sign:
        part += item
        if part in SignToChar:
            string += SignToChar[part]
            part = ""
    print(string)

-    sign = [] +    sign = "" -        convert = CharToSign[char] -        sign.append(convert) -    sign = "".join(sign) -    startIndex = 0 -    endIndex = 3 -    string = [] -    length = len(sign) -    while endIndex <= length: -        part = sign[startIndex:endIndex] +        sign += CharToSign[char] +    string = "" +    part = "" +    for item in sign: +        part += item -            convert = SignToChar[part] -            string.append(convert) -            startIndex = endIndex -            endIndex += 3 -        else: -            endIndex += 1 -    string = "".join(string) +            string += SignToChar[part] +            part = ""