(* Examples *)
(*
stdin.ReadLine()
printfn "%d"
printfn "%s"
*)

(* Library *)
module Library =
  let powerSet (n : int) =
    [|0 .. (1 <<< n) - 1|]
    |> Array.map (fun x ->
      [|0 .. n - 1|]
      |> Array.map(fun y -> x &&& (1 <<< y) <> 0)
    )

(* Standard Input *)
let readSplit elementFun=
  stdin.ReadLine().Split()
  |> Array.map elementFun

let read elementFun =
  stdin.ReadLine() |> elementFun

let readMap H =
  [|for i in 1..H -> stdin.ReadLine()|]
  |> Array.map(fun line ->
    line.ToCharArray()
  )
  |> array2D

(* Main *)
open Library

let N = read int

let table = 
  [|for i in 1..N ->
    let A = read int
    [|for j in 1..A ->
      readSplit int
    |]
  |]

powerSet N
|> Array.filter (fun group ->
  let mutable p = -1
  group |> Array.forall (fun person ->
    p <- p + 1
    match person with 
    | true ->
      table.[p] |> Array.forall (fun pre ->
        group.[pre.[0] - 1] = (if pre.[1] = 1 then true else false)
      )
    | false -> true
  )
)
|> Array.map(fun group ->
  group |> Array.fold (fun count i -> count + (if i then 1 else 0)) 0
)
|> Array.max
|> printfn "%d"