n,m = map(int,input().split())
K = []

for i in range(m):
    l = list(map(int,input().split()))
    K.append(l[1:])
res = 0
p = list(map(int,input().split()))
for i in range(2**n):
    s=format(i,'#0'+str(n)+'b')
    s=s[2:]
    cnt = [0]*m
    for j in range(len(s)):
        for k in range(len(K)):
            if s[j]=='1' and (j+1) in K[k]:
                cnt[k]+=1
    flag = True

    for j in range(len(cnt)):
        if cnt[j]%2 != p[j]:
            flag = False
            break
    if flag:
        res += 1 
print(res)
