#include <stdio.h>
#define num 54
int k;
int muta[num+1];//保存变换规则1-54,0位置不用
int poke[num+1];//保存原始poke的编号;
int aftermt[num+1];//保存变换后的poke编号
void mutate(){
for (int i=1; i<=num; i++) {
int newpos=muta[i];
aftermt[newpos]=poke[i];
}
for (int i=1; i<=num; i++) {
poke[i]=aftermt[i];//poke中永远保存着要输出的值
}
}
void output(){
for (int i=1; i<=num; i++) {
if (1<=poke[i]&&poke[i]<=13) {
printf("S%d",poke[i]);
}
if (14<=poke[i]&&poke[i]<=26) {
printf("H%d",poke[i]-13);
}
if (27<=poke[i]&&poke[i]<=39) {
printf("C%d" ,poke[i]-26);
}
if (40<=poke[i]&&poke[i]<=52) {
printf("D%d",poke[i]-39);
}
if (53<=poke[i]&&poke[i]<=54) {
printf("J%d",poke[i]-52);
}
if (i==num)
printf("\n");
else
printf(" ");
}
}
int main(){
freopen("/Users/pantingting/Documents/code/data/input", "r", stdin);
scanf("%d",&k);
for (int i=1; i<=num; i++) {
poke[i]=i;
}
for (int i=1; i<=num; i++) {
scanf("%d",&muta[i]);
}
for (int i=1; i<=k; i++) {
mutate();
}
output();
return 0;
}