#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<unordered_map>
#include<algorithm>
#define maxn 55
using namespace std;
int main() {
int card[maxn], shuffle[maxn], temp[maxn];
int k;
scanf("%d", &k);
for (int i = 1; i < maxn; i++) {
scanf("%d", &shuffle[i]);
card[i] = i;
}
while(k--) {
for (int i = 0; i < maxn; i++) {
temp[i] = card[i];
}
for (int i = 0; i < maxn; i++) {
card[shuffle[i]] = temp[i];
}
}
char c[5] = {'S', 'H', 'C', 'D', 'J' };
for (int i = 1; i < maxn; i++) {
int t = card[i] - 1;
int a = t / 13;
t = t % 13 + 1;
printf("%c%d", c[a], t);
if (i != maxn - 1) printf(" ");
else printf("\n");
}
}