let stream_map f stream = Stream.from (fun _ -> try Some (f (Stream.next stream)) with Stream.Failure -> None) let stream_fold f init st = let result = ref init in Stream.iter (fun x -> result := f !result x) st; !result let solve ts_st = ts_st |> stream_map (fun (t, s) -> let len_s = String.length s and len_t = t * 12 / 1000 in let r = if len_s <= len_t then len_s else len_t in (r, len_s - r)) |> stream_fold (fun (x1, y1) (x2, y2) -> (x1 + x2, y1 + y2)) (0, 0) let () = let n = read_line () |> int_of_string in let ts_st = Stream.from (fun i -> if i >= n then None else read_line () |> fun l -> Scanf.sscanf l "%d %s" (fun t s -> Some(t, s)) ) in solve ts_st |> fun (x, y) -> Printf.printf "%d %d\n" x y