import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		while(n-->0){
			String str = in.nextLine();
			StringBuffer out = new StringBuffer();
			StringBuffer tem = new StringBuffer();
			for(int i=0;i<str.length();i++){
				char c = str.charAt(i);
				if(c=='#'){
					if(tem.length()!=0)out.append((char)('A'+Integer.parseInt(tem.toString())-1));
					out.append(' ');
					tem.delete(0, tem.length());
				}else if(c=='-'){
					if(tem.length()!=0)out.append((char)('A'+Integer.parseInt(tem.toString())-1));
					tem.delete(0, tem.length());
				}else tem.append(c);
			}
			if(tem.length()!=0)out.append((char)('A'+Integer.parseInt(tem.toString())-1));
			System.out.println(out);
		}
	}

}

/**************************************************************
	Problem: 2035
	User: admin
	Language: Java
	Result: Accepted
	Time:696 ms
	Memory:40276 kb
****************************************************************/