private void doMain(BufferedReader reader, PrintStream writer) throws Exception {

		int n = Integer.parseInt(reader.readLine());
		
		for (int i = 0; i != n; ++i) {
			
			String message = reader.readLine().toUpperCase();
			
			StringBuilder code = new StringBuilder();
			
			for (int c = 0; c != message.length(); ++c) {
				
				char ch = message.charAt(c);
				
				if (ch == ' ') {
					if (code.length() > 0 && code.charAt(code.length() - 1) == '0') {
						code.append(' ');
					}
					code.append('0');
				}
				else {
					String sequence = map.get(Character.toString(ch));
					if (sequence != null) {
						
						if (code.length() > 0 && sequence.charAt(0) == code.charAt(code.length()-1)) {
							code.append(' ');
						}
						
						code.append(sequence);
					}
				}

			}
			
			//while(code.length() > 0 && code.charAt(code.length() -1) == '0') {
			//	code.setLength(code.length() - 1);
			//}
			
			writer.println("Case #" + (i+1) + ": " + code);
			
		}
		
	}