d = {".-":"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"}
for t in range(1,int(input())+1):
s = input()
L = s.split()
print("Case {}: {}".format(t,"".join([d[i] for i in L])))