!true:honest
!false:unkind
      module piyoMod
      implicit none
      
      type persons
        integer :: a=0,x(14)
        logical :: y(14)
      end type
      end module
      
      PROGRAM HonestOrUnkind2
      use piyoMod
      IMPLICIT NONE
      integer :: n,ans=0
      type(persons),allocatable :: person(:)
      logical,allocatable :: tempP(:)
      integer :: i,j,k,buffer(2)
      logical :: expect
      
      read*,n
      allocate( person(n),tempP(n) )
      do i = 1,n
        read*,person(i)%a
        do k = 1,person(i)%a
          read*,buffer(1:2)
          person(i)%x(k) = buffer(1)
          if( buffer(2)==1 )then
            person(i)%y(k) = .true.
          else
            person(i)%y(k) = .false.
          end if
        end do
      end do
 !   print*,n
 !   do i = 1,n
 !     print*,person(i)%a
 !     do k = 1,person(i)%a
 !       print*,person(i)%x(k),person(i)%y(k)
 !     end do
 !   end do
      
      
      outer:do i = 0,2**n-1
        do k = 1,n
          tempP(k) = btest( i,k-1 )
        end do
!print*,tempP
        
        do j = 1,n
          if( tempP(j) )then
            
            do k = 1,person(j)%a
              expect = person(j)%y(k)
              if( tempP(person(j)%x(k)).neqv.expect )then
                cycle outer
              end if
            end do
          end if
        end do
        
        ans = max( ans,count(tempP(1:n)) )
        
        
      end do outer
      
      print*,ans
      
      
      END PROGRAM