N, M = map(int, input().split())

A=[]
total=0
count=0
flag=0
for j in range(M+1):
    A.append(list(map(int, input().split())))

for i in range(2**N):
    switch=format(i,'b')
    switch=switch[::-1]+'0000000000'
    

    for a in range(M):
        for b in range(1,len(A[a])):
            
            count += int(switch[int(A[a][b])-1])
            

        if count%2!=A[M][a]:
            flag=1
    if flag==0:
        total +=1
    flag=0
    count=0



print(total)