n,m = list(map(int,input().split()))
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(1,2**n):
    flag = True
    for j in range(m): #電球
        cnt = 0
        for k in range(1,len(ks[j])):
            w = ks[j][k]
            if i >> (w-1) & 1 :
                cnt+=1
        if cnt%2 != p[j]:
            flag = False
    if flag:
        ans+=1
print(ans)