n,m=map(int,input().split())
list1=[]
for i in range(m):
    a=list(map(int,input().split()))
    list1.append(a)
p=list(map(int,input().split()))

num=2**n
count=0
for i in range(num):
    lump=1
    x=[]
    for j in range(n):
        x.append((i*2//(2**(j+1)))% 2)
    for k in range(m):
        sum=0
        for k1 in range(len(list1[k][1:])):
            if x[list1[k][k1]-1]==1:
                sum=sum+1
        if sum % 2!=p[k]:
            lump=0
    if lump==1:
        count=count+1
print(count)
