#include <stdio.h>
#include <string.h>
int main ()
{
int n , i ,t ,p ,j , nw =0 ;
char s [110] ;
scanf ("%d",&t) ;
getchar () ;
for (i=1 ; i<= t ; i++)
{
if (nw == 1) printf ("\n") ;
nw = 1 ;
while ( gets (s))
{
if (strlen (s) == 0) break ;
for (j =0 ; j < strlen (s) ; j++)
{
if (s[j] == '3' ) s[j] = 'E' ;
if (s[j] == '0' ) s[j] = 'O' ;
if (s[j] == '1' ) s[j] = 'I' ;
if (s[j] == '4' ) s[j] = 'A' ;
if (s[j] == '8' ) s[j] = 'B' ;
if (s[j] == '5' ) s[j] = 'S' ;
if (s[j] == '7' ) s[j] = 'T' ;
if (s[j] == '2' ) s[j] = 'Z' ;
if (s[j] == '6' ) s[j] = 'G' ;
if (s[j] == '9' ) s[j] = 'P' ;
}
puts (s) ;
}
}
return 0 ;
}
#include <string.h>
int main ()
{
int n , i ,t ,p ,j , nw =0 ;
char s [110] ;
scanf ("%d",&t) ;
getchar () ;
for (i=1 ; i<= t ; i++)
{
if (nw == 1) printf ("\n") ;
nw = 1 ;
while ( gets (s))
{
if (strlen (s) == 0) break ;
for (j =0 ; j < strlen (s) ; j++)
{
if (s[j] == '3' ) s[j] = 'E' ;
if (s[j] == '0' ) s[j] = 'O' ;
if (s[j] == '1' ) s[j] = 'I' ;
if (s[j] == '4' ) s[j] = 'A' ;
if (s[j] == '8' ) s[j] = 'B' ;
if (s[j] == '5' ) s[j] = 'S' ;
if (s[j] == '7' ) s[j] = 'T' ;
if (s[j] == '2' ) s[j] = 'Z' ;
if (s[j] == '6' ) s[j] = 'G' ;
if (s[j] == '9' ) s[j] = 'P' ;
}
puts (s) ;
}
}
return 0 ;
}