def sum(A):
    a=0
    for num in range(len(A)):
        a=a+A[num]
    return a
             


N,M=input().split()
N=int(N)
M=int(M)
K=[100]*(M+1)
for num in range(M+1):
    K[num]=input().split()
    for num2 in range(len(K[num])):
        K[num][num2]=int(K[num][num2])

a=[0]*N
cnt=0
for num in range(pow(2,N)):
    flag=0
    n=num
    i=0
    while(N>i):
        a[N-1-i]=n//pow(2,N-1-i)
        if(a[N-1-i]==1):
            n=n-pow(2,N-1-i)
        i=i+1
    b=0
    for num2 in range(M):
        for num3 in range(len(K[num2])-1):
            b=b+a[K[num2][num3+1]-1]
        if(b%2!=K[M][num2]):
            flag=1
    if(flag==0):
        cnt=cnt+1
print(cnt)
