let ans, n = ref 0, read_int ()
let fs, qs = Array.(make n 0, init n @@ fun _ -> Scanf.(scanf " %d" @@ fun a -> init a @@ fun _ -> scanf " %d %d" @@ fun a b -> a - 1, b))
let g _ = let c, b = ref 0, ref true in for i = 0 to n - 1 do if fs.(i) = 1 then (incr c; b := !b && Array.fold_left (fun b (x, y) -> b && fs.(x) = y) !b qs.(i)) done; if !b then !c else 0
let rec f i = if i >= n then ans := max !ans @@ g () else (fs.(i) <- 1; f (i + 1); fs.(i) <- 0; f (i + 1))
let _ = f 0; Printf.printf "%d\n" !ans