let n, ans = read_int (), ref min_int
let h m = Array.(init n @@ fun _ -> init m @@ fun _ -> Scanf.scanf " %d" (+) 0)
let fs = h 10
let ps = h 11
let f b = Array.(fold_left (fun (s, i) f -> s + ps.(i).(fst @@ fold_left (fun (c, j) o -> c + (o + (b lsr j) land 1) / 2, j + 1) (0, 0) f), i + 1) (0, 0) fs) |> fst
let _ = for i = 1 to 1023 do ans := max !ans @@ f i done; Printf.printf "%d\n" !ans