#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <map>

using namespace std;

void make_encode(map<char, string> &encode)
{
	encode['A'] = "00000"; encode['I'] = "01000"; encode['Q'] = "10000"; encode['Y'] = "11000";
	encode['B'] = "00001"; encode['J'] = "01001"; encode['R'] = "10001"; encode['Z'] = "11001";
	encode['C'] = "00010"; encode['K'] = "01010"; encode['S'] = "10010"; encode[' '] = "11010";
	encode['D'] = "00011"; encode['L'] = "01011"; encode['T'] = "10011"; encode['.'] = "11011";
	encode['E'] = "00100"; encode['M'] = "01100"; encode['U'] = "10100"; encode[','] = "11100";
	encode['F'] = "00101"; encode['N'] = "01101"; encode['V'] = "10101"; encode['-'] = "11101";
	encode['G'] = "00110"; encode['O'] = "01110"; encode['W'] = "10110"; encode['\''] = "11110";
	encode['H'] = "00111"; encode['P'] = "01111"; encode['X'] = "10111"; encode['?'] = "11111";
}

void make_decode(map<string, char> &decode)
{
	decode["101"] = ' ';		decode["0101"] = 'C';		decode["0110"] = 'K';		decode["00110"] = 'S';
	decode["000000"] = '\'';	decode["0001"] = 'D';		decode["00100"] = 'L';		decode["00111"] = 'T';
	decode["000011"] = ',';		decode["110"] = 'E';		decode["10011001"] = 'M';	decode["10011100"] = 'U';
	decode["10010001"] = '-';	decode["01001"] = 'F';		decode["10011110"] = 'N';	decode["10011101"] = 'V';
	decode["010001"] = '.';		decode["10011011"] = 'G';	decode["00101"] = 'O';		decode["000010"] = 'W';
	decode["000001"] = '?';		decode["010000"] = 'H';		decode["111"] = 'P';		decode["10010010"] = 'X';
	decode["100101"] = 'A';		decode["0111"] = 'I';		decode["10011111"] = 'Q';	decode["10010011"] = 'Y';
	decode["10011010"] = 'B';	decode["10011000"] = 'J';	decode["1000"] = 'R';		decode["10010000"] = 'Z';
}

void Decode(string &bin)
{
	string sub;
	bool flag = false;

	while (!bin.empty()){

		if (bin == "0" || bin == "00" || bin == "000" || bin == "0000" ||
			bin == "00000" || bin == "000000" || bin == "0000000") break;

		sub = bin.substr(0, 3);
		if (sub == "111")		{ cout << 'P';	flag = true; }
		else if (sub == "110")	{ cout << 'E';	flag = true; }
		else if (sub == "101")	{ cout << ' ';	flag = true; }
		if (flag) {
			flag = false;
			bin.erase(0, 3);
			continue;
		}

		sub = bin.substr(0, 4);
		if (sub == "1000")		{ cout << 'R';	flag = true; }
		else if (sub == "0111") { cout << 'I';	flag = true; }
		else if (sub == "0110") { cout << 'K';	flag = true; }
		else if (sub == "0101") { cout << 'C';	flag = true; }
		else if (sub == "0001") { cout << 'D';	flag = true; }
		if (flag) {
			flag = false;
			bin.erase(0, 4);
			continue;
		}

		sub = bin.substr(0, 5);
		if (sub == "01001")		 { cout << 'F';		flag = true; }
		else if (sub == "00111") { cout << 'T';		flag = true; }
		else if (sub == "00110") { cout << 'S';		flag = true; }
		else if (sub == "00101") { cout << 'O';		flag = true; }
		else if (sub == "00100") { cout << 'L';		flag = true; }
		if (flag) {
			flag = false;
			bin.erase(0, 5);
			continue;
		}

		sub = bin.substr(0, 6);
		if (sub == "100101")	  { cout << 'A';	flag = true; }
		else if (sub == "010001") { cout << '.';	flag = true; }
		else if (sub == "010000") { cout << 'H';	flag = true; }
		else if (sub == "000011") { cout << ',';	flag = true; }
		else if (sub == "000010") { cout << 'W';	flag = true; }
		else if (sub == "000001") { cout << '?';	flag = true; }
		else if (sub == "000000") { cout << '\'';	flag = true; }
		if (flag) {
			flag = false;
			bin.erase(0, 6);
			continue;
		}

		sub = bin.substr(0, 8);
		if (sub == "10011111")		{ cout << 'Q';	flag = true; }
		else if (sub == "10011110") { cout << 'N';	flag = true; }
		else if (sub == "10011101") { cout << 'V';	flag = true; }
		else if (sub == "10011100") { cout << 'U';	flag = true; }
		else if (sub == "10011011") { cout << 'G';	flag = true; }
		else if (sub == "10011010") { cout << 'B';	flag = true; }
		else if (sub == "10011001") { cout << 'M';	flag = true; }
		else if (sub == "10011000") { cout << 'J';	flag = true; }
		else if (sub == "10010011") { cout << 'Y';	flag = true; }
		else if (sub == "10010010") { cout << 'X';	flag = true; }
		else if (sub == "10010001") { cout << '-';	flag = true; }
		else if (sub == "10010000") { cout << 'Z';	flag = true; }
		if (flag){
			flag = false;
			bin.erase(0, 8);
			continue;
		}

	}
	cout << endl;
}

int main()
{
	map<char, string> encode;
	make_encode(encode);

	map<string, char> decode;
	make_decode(decode);

	int c = getchar();
	while (c != EOF){
		string bin;
		while (c != '\n'){
			bin.append(encode[(char)c]);
			c = getchar();
		}
		Decode(bin);
		c = getchar();
	}
	return 0;
}