#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<string,char> mp;
int main(){
cin>>n;
mp[".-"]='A';mp["-..."]='B';mp["-.-."]='C';mp["-.."]='D';
mp["."]='E';mp["..-."]='F';mp["--."]='G';mp["...."]='H';
mp[".."]='I';mp[".---"]='J';mp["-.-"]='K';mp[".-.."]='L';
mp["--"]='M';mp["-."]='N';mp["---"]='O';mp[".--."]='P';
mp["--.-"]='Q';mp["-.-"]='R';mp["..."]='S';mp["-"]='T';
mp["..-"]='U';mp["...-"]='V';mp[".--"]='W';mp["-..-"]='X';
mp["-.--"]='Y';mp["--.."]='Z';
for(int i=1;i<=n;i++){
cin>>s;
cout<<mp[s];
}
return 0;
}