let rec make_list n l =
	match n with
	|0 -> l
	|_ -> Scanf.sscanf(read_line()) "%s %d" (fun x y -> make_list (n-1) ((x,y)::l));;

let suits = ["S";"H";"C";"D"];;
let nums = [1;2;3;4;5;6;7;8;9;10;11;12;13];;

let find l =
	let rec search l tup =
		match l with
		|[] -> false
		|x::xs -> if x = tup then true else search xs tup
	in
	let rec find_n l su nus res =
		match nus with
		|[] -> res
		|x::xs -> if search l (su,x) then find_n l su xs res else find_n l su xs ((su,x)::res)
	in
	let rec find_s l sus nus res = 
		match sus with
		|[] -> res
		|x::xs -> let res2 = find_n l x nus res in find_s l xs nus res2
	in
	find_s l suits nums [];;

let rec print_tups l =
	match l with
	|[] -> ()
	|(s,n)::ts -> print_tups ts;Printf.printf "%s %d\n" s n;;

let n = Scanf.sscanf(read_line()) "%d" (fun x -> x)
in
print_tups (find (make_list n []));;

