Scanf.scanf "%d" (fun n ->
    let s = Array.init n (fun _ -> Scanf.scanf " %s" (fun a -> a)) in

    let rec loop i ac wa tle re =
        if i = n then Printf.printf "AC x %d\nWA x %d\nTLE x %d\nRE x %d\n" ac wa tle re else
            match s.(i) with
            | "AC"  -> loop (i + 1) (ac + 1) wa tle re
            | "WA"  -> loop (i + 1) ac (wa + 1) tle re
            | "TLE" -> loop (i + 1) ac wa (tle + 1) re
            | "RE"  -> loop (i + 1) ac wa tle (re + 1)
            | _ -> failwith "??"
    in
    loop 0 0 0 0 0
)