let matrix = Array.init 10 (fun x -> Array.init 10 (fun y -> 0));;

let small x y =
  matrix.(x).(y) <- matrix.(x).(y);
  if x > 0 then matrix.(x-1).(y) <- (matrix.(x-1).(y)+1);
  if y > 0 then matrix.(x).(y-1) <- (matrix.(x).(y-1)+1);
  if x < 9 then matrix.(x+1).(y) <- (matrix.(x+1).(y)+1);
  if y < 9 then matrix.(x).(y+1) <- (matrix.(x).(y+1)+1)
;;

let medium x y =
  small x y;
  if x > 0 then
    begin
      if y > 0 then matrix.(x-1).(y-1) <- (matrix.(x-1).(y-1)+1);
      if y < 9 then matrix.(x-1).(y+1) <- (matrix.(x-1).(y+1)+1);
    end;
  if x < 9 then
    begin
      if y > 0 then matrix.(x+1).(y-1) <- (matrix.(x+1).(y-1)+1);
      if y < 9 then matrix.(x+1).(y+1) <- (matrix.(x+1).(y+1)+1);
    end;
;;

let large x y =
  medium x y;
  if x > 1 then matrix.(x-2).(y) <- (matrix.(x-2).(y)+1);
  if y > 1 then matrix.(x).(y-2) <- (matrix.(x).(y-2)+1);
  if x < 8 then matrix.(x+2).(y) <- (matrix.(x+2).(y)+1);
  if y < 8 then matrix.(x).(y+2) <- (matrix.(x).(y+2)+1)
;;

let () =
  let rec read () =
    try let l = read_line () |> Str.split (Str.regexp ",")
                |> List.map int_of_string
                |> Array.of_list
        in
        if l.(2) = 1 then small l.(0) l.(1)
        else if l.(2) = 2 then medium l.(0) l.(1)
        else large l.(0) l.(1)
        ;read ()
    with End_of_file ->
      let count, max =
        Array.fold_left (fun x1 y1 -> Array.fold_left (fun x2 y2 -> if y2 = 0 then x2+1 else x2) x1 y1) 0 matrix,
        Array.fold_left (fun x1 y1 -> Array.fold_left (fun x2 y2 -> if y2 > x2 then y2 else x2) x1 y1) 0 matrix
      in
      Printf.printf "%d\n%d\n" count max
  in read ()
;;