#include <stdio.h>
int main(void){
// 시험문제 개수 입력
int test_case = 0;
scanf("%d", &test_case);
for(int i = 0; i < test_case; i++){
// 알파벳 또는 숫자 개수, 문제 종류 입력
int num = 0, type = 0;
scanf("%d %c", &num, &type);
for(int j = 0; j < num; j++){
getchar(); // 버퍼 비우기
int answer = 0;
// 문제 종류가 알파벳을 숫자로 바꾸는 경우
if(type == 67){
scanf("%c", &answer);
printf("%d ", answer - 64);
}
// 문제 종류가 숫자를 알파벳로 바꾸는 경우
else if(type == 78){
scanf("%d", &answer);
printf("%c ", answer + 64);
}
}
printf("\n");
}
return 0;
}