// Arup Guha
// 10/18/2013
// Solution to 2008 MCPC Problem H: Steganography

import java.util.*;

public class h {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		String line = stdin.nextLine();

		// Go through each case.
		while (true) {

			String msg = "";
			line = stdin.nextLine();

			// Done!
			if (line.equals("#")) break;

			// Read in whole message.
			while (!line.equals("*")) {
				msg = msg+line;
				line = stdin.nextLine();
			}

			// Output solution.
			System.out.println(solve(msg));
		}
	}

	public static String solve(String s) {

		// Extract out sequences of spaces. odd = false, even = true
		ArrayList<Boolean> spaces = getSpaceSeq(s);

		// Pad with 0s.
		while (spaces.size()%5 != 0)
			spaces.add(false);

		// Get numeric codes, then convert to String.
		int[] codes = getCodes(spaces);
		return getStr(codes);
	}

	public static ArrayList<Boolean> getSpaceSeq(String s) {

		ArrayList<Boolean> ans = new ArrayList<Boolean>();

		int i = 0;
		while (i < s.length()) {

			while (i < s.length() && s.charAt(i) != ' ') i++;

			// Count this gap of spaces.
			int cnt = 0;
			while (i < s.length() && s.charAt(i) == ' ') {
				i++;
				cnt++;
			}

			// Shouldn't add this, it's not a sequence of spaces.
			if (cnt == 0) break;

			// Add this bit.
			if (cnt%2 == 1) ans.add(false);
			else            ans.add(true);
		}

		// List of bits.
		return ans;
	}

	public static int[] getCodes(ArrayList<Boolean> spaces) {

		int[] ans = new int[spaces.size()/5];

		// Go through each block.
		for (int i=0; i<spaces.size(); i+=5) {

			// Get value for this block.
			int value = 0;
			for (int j=0; j<5; j++) {
				int bit = 0;
				if (spaces.get(i+j))
					bit = 1;
				value = 2*value + bit;
			}

			// Store it.
			ans[i/5] = value;
		}

		return ans;
	}

	// Convert each character and return.
	public static String getStr(int[] codes) {
		String s = "";
		for (int i=0; i<codes.length; i++)
			s = s + convert(codes[i]);
		return s;
	}

	// Their silly conversion list...
	public static char convert(int code) {
		if (code == 0) return ' ';
		if (code <= 26) return (char)('A'+code-1);
		if (code == 27) return '\'';
		if (code == 28) return ',';
		if (code == 29) return '-';
		if (code == 30) return '.';
		return '?';
	}
}