char*a="DCHSA23456789TJQK";b[99][99],i,j;main(k){for(gets(&k);~scanf("%c%c ",&k,&j);b[k][j]++);for(;j=i<4;i++)for(;++j<17;)b[a[i]][a[j]]&&printf("%c%c ",a[i],a[j]);}