Module Module1

    Dim N As Integer = 0
    ' 証言者iがxに対する証言yをtblに保存
    ' tbl(i,x) = y 
    ' ※ただし配列の0から格納していくため1人目の証言者はi=0として以降順番に格納するものとする
    ' y：0⇒不親切, 1⇒正直者 -1⇒証言なし
    Dim tbl(14, 14) As Integer

    Sub Main()

        N = Int(Console.ReadLine)
        Dim result As Integer = 0

        For i As Integer = 0 To 14
            For j As Integer = 0 To 14
                tbl(i, j) = -1
            Next
        Next

        For i As Integer = 0 To N - 1
            Dim a As Integer = Int(Console.ReadLine)
            For j As Integer = 1 To a
                Dim arr() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)
                Dim x, y As Integer
                x = arr(0) : y = arr(1)
                tbl(i, x - 1) = y
            Next
        Next

        ' bit全探索（bitで15桁を作成し0桁目をA0とし、1を正直者0を不親切な人とする）
        For i As Int64 = 1 To (1 << N) - 1
            Dim honests(N - 1) As Integer
            ' 
            For j As Integer = 0 To N - 1
                If (i >> j) And 1 Then
                    honests(j) = 1
                End If
            Next
            Dim b As Boolean = True
            For j As Integer = 0 To N - 1
                ' jが正直者であれば証言に矛盾がないか確認する
                If honests(j) = 1 Then
                    For k As Integer = 0 To N - 1
                        ' 証言者jのkに対する証言に矛盾がないかを確認
                        ' 矛盾があれば次へ
                        If tbl(j, k) = -1 Then
                            Continue For
                        ElseIf tbl(j, k) <> honests(k) Then
                            b = False
                            Exit For
                        End If
                    Next
                End If
            Next
            If b Then
                Dim count As Integer = 0
                For k As Integer = 0 To N - 1
                    If honests(k) = 1 Then
                        count = count + 1
                    End If
                Next
                result = Math.Max(result, count)
            End If
        Next
        Console.WriteLine(result)
    End Sub

End Module
