#include <cstdio>
#include <iostream>
#include <cstring>
int cards[55];
void init(){
for (int i=1; i<55; i++)
cards[i] = i;
}
char shape[] = {'S','H','C','D','J'};
int pos[55];
int main(){
int n;
scanf("%d",&n);
for (int i=1; i<55; i++)
scanf("%d",&pos[i]);
init();
int temp[55];
while (n--) {
for (int i = 1; i<55; i++)
temp[pos[i]] = cards[i];
for (int i = 1; i<55; i++) {
cards[i] = temp[i];
}
}
for (int i=1; i<55; i++){
if(i != 1)
printf(" ");
cards[i]--;
printf("%c%d",shape[cards[i]/13],cards[i]%13+1);
}
// printf("%c%d ",shape[cards[i]/13],cards[i]%13+1);
// printf("%c%d",shape[cards[54]/13],cards[54]%13+1);
}