Title: Doctor's Code

Doctor: ?D-C'KOPUA

Peter: What's wrong, Doctor David? I'm used to you shouting incomprehensible things, but today, you can't even form a sentence.

Doctor: Look.

[Image: Memorable Codes 1]

Peter: What's this? This table... Oh, there was something like this in the preliminary round. Using the table to replace letters reduces the number of characters. They wouldn't be lazy enough to use the same problem in both the preliminary and final rounds, would they?

Doctor: It's the opposite.

Peter: The opposite? I see, this time it's a problem of restoring a shortened string to its original form. So, we use this table to replace the characters in "?D-C'KOPUA" with "codes" instead of "letters"... I've done it.

11111 00011 11101 00010 11110 01010 01110 01111 10100 00000

Doctor: Yes, now this.

[Image: Memorable Codes 2]

Peter: Right, there was a table like this. We use it in reverse, so we need to replace "codes" with "letters." But, initially, "11111" isn't in the table, is it?

Doctor: In such cases, try shortening it or connecting it to the end.

Peter: Then, if I shorten it... Ah, "111" is there. So, initially it's "P," right? Then the remaining "11" doesn't match exactly, so I borrow one letter from "00011" to make it "110."

Doctor: Exactly, that's "E."

Peter: So, what remains is "0011," so I borrow from the next to make it "00111" to get "T"... I'm done. I can just discard the final "0000," right?

Doctor: Yes, that's right. Now this.

[Image: Memorable Codes 3]

Doctor: And this one.

?P'QNPY?IXX?IXXK.BI -G?R'RPP'RPOVWDMW?SWUVG'-LCMGQ

Doctor: Finally, this.

?P'QMDUEQ GADKOQ ?SWUVG'-LCMG?X?IGX,PUL.?UL.VNQQI

Peter: It's quite a hassle. Doctor, next time, please make the program yourself.

So, instead of the doctor, please create a program to replace the above text.

Input:
Multiple datasets are given. For each dataset, a single string (up to 200 characters consisting of characters in the table) is provided on a single line. Process until the end of input. The number of datasets does not exceed 200.

Output:
For each dataset, output the converted string on a single line.

Sample Input:
?D-C'KOPUA

Output for the Sample Input:
PETER POTTER

# Buggy version:
#! python.exe
dic = {}
for idx, c in enumerate("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"):
    dic[c] = str(format(idx,'b').zfill(5))


decode = {"101"      : " ", "0101"     : "C", "0110"     : "K", "00110" : "S",
          "000000"   : "'", "0001"     : "D", "00100"    : "L", "00111" : "T",
          "000011"   : ",", "110"      : "E", "10011001" : "M", "10011100" : "U",
          "10010001" : "-", "01001"    : "F", "10011110" : "N", "10011101" : "V",
          "010001"   : ".", "10011011" : "G", "00101"    : "O", "000010"   : "W",
          "000001"   : "?", "010000"   : "H", "111"      : "P", "10010010" : "X",
          "100101"   : "A", "0111"     : "I", "10011111" : "Q", "10010011" : "Y",
          "10011010" : "B", "10011000" : "J", "1000"     : "R", "10010000" : "Z"}
print(dic)
while True:
    try:
        line = input()
    except:
        break
    s = ""
    for c in line:
        s += dic[c]
    ans = ""
    while s.count("1") :
        for key in decode:
            n = len(key)
            if s[0:n] == key:
                ans += decode[key]
                s = s[n:]
                break
#        print(ans, s)
    print(ans)

# Fixed version:
#! python.exe
dic = {}
for idx, c in enumerate("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"):
    dic[c] = str(format(idx,'b').zfill(5))

decode = {"101"      : " ", "0101"     : "C", "0110"     : "K", "00110"    : "S",
          "000000"   : "'", "0001"     : "D", "00100"    : "L", "00111"    : "T",
          "000011"   : ",", "110"      : "E", "10011001" : "M", "10011100" : "U",
          "10010001" : "-", "01001"    : "F", "10011110" : "N", "10011101" : "V",
          "010001"   : ".", "10011011" : "G", "00101"    : "O", "000010"   : "W",
          "000001"   : "?", "010000"   : "H", "111"      : "P", "10010010" : "X",
          "100101"   : "A", "0111"     : "I", "10011111" : "Q", "10010011" : "Y",
          "10011010" : "B", "10011000" : "J", "1000"     : "R", "10010000" : "Z"}
#print(dic)
while True:
    try:
        line = input()
    except:
        break
    s = ""
    for c in line:
        s += dic[c]
    ans = ""
    tmp = ""
    for c in s:
        tmp += c
        if tmp in decode:
            ans += decode[tmp]
            tmp = ''
#        print(ans, s)
    print(ans)