code_a = Hash[
*%w(
'   000000
,   000011
-   10010001
.   010001
?   000001
A   100101
B   10011010
C   0101
D   0001
E   110
F   01001
G   10011011
H   010000
I   0111
J   10011000
K   0110
L   00100
M   10011001
N   10011110
O   00101
P   111
Q   10011111
R   1000
S   00110
T   00111
U   10011100
V   10011101
W   000010
X   10010010
Y   10010011
Z   10010000
) +
[' ', '101']
]

code_a = code_a.invert
 
code_b = Hash[*%w(
11011   .
11100   ,
11101   -
11110   '
11111   ?
)] 
(?A..?Z).each{|c|
	code_b["%05b" % (c.ord - ?A.ord)] = c
}
code_b['11010'] = " "

code_b = code_b.invert

while gets
	ans = []
	s = $_
		.chomp
		.each_char
		.map{|c| code_b[c]}
		.join
	loop do
		i = 0
		i += 1 until i >= s.size || x = code_a[s[0..i]]
		break if i >= s.size
		ans << x
		s = s[i+1..-1]
	end
	puts ans.join
end