char*a="*DCHSA23456789TJQK";b[99][99],i,j;main(k){for(;~scanf("%c%c ",&k,&j)?++b[k][j]:++j>17?j=++i<5:!b[a[i]][a[j]]||printf("%c%c ",a[i],a[j]););}