#include <bits/stdc++.h> //d353 //b969 //b523 //b524 //b526 //a538
#define fast_as_a_fuckboy ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
fast_as_a_fuckboy
int n;
cin >> n;
string s;
map<string,string> m={{".-","A"},{"-...","B"},{"-.-.","C"},{"-..","D"},{".","E"},{"..-.","F"},{"--.","G"},{"....","H"},{"..","I"},{".---","J"},{"-.-","K"},{".-..","L"},{"--","M"},{"-.","N"},{"---","O"},{".--.","P"},{"--.-","Q"},{".-.","R"},{"...","S"},{"-","T"},{"..-","U"},{"...-","V"},{".--","W"},{"-..-","X"},{"-.--","Y"},{"--..","Z"}};
cin.ignore();
for(int i=0;i<=n;i++){ // 就是這行,照理來說 i < n 就可以輸出正確的範例,但居然要加一個=?????
getline(cin,s);
stringstream ss(s);
while(ss>>s){
cout << m[s];
}
cout << "\n";
s.clear();
}
}