#include<stdio.h>
using namespace std;
int main() {
char mp[5] = { 'S', 'H', 'C','D', 'J' };
int n, start[55] = { 0 }, order[55] = { 0 }, renew[55] = { 0 }; // n为洗牌次数
scanf("%d", &n);
for (int i = 1; i < 55; i++) {
start[i] = i;
}
for (int i = 1; i < 55; i++) {
scanf("%d", &order[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 1; j < 55; j++) {
renew[order[j]] = start[j];
}
for (int k = 1; k < 55; k++) {
start[k] = renew[k];
}
}
for (int i = 1; i < 55; i++) {
if (i != 1) printf(" ");
printf("%c%d", mp[(renew[i] - 1) / 13], (renew[i] - 1) % 13 + 1);
}
return 0;
}