let () = Scanf.scanf "%d\n" @@ fun m ->
  let dcs = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun d c -> d, c in
  let digitsum, digit =
    Array.fold_left (fun (digitsum, digit) (d, c) ->
      digitsum + d * c, digit + c) (0, 0) dcs in
  Printf.printf "%d\n" @@ (digitsum - 1) / 9 + digit - 1

