N, M = map(int, input().split())
l=[]
for i in range(M):
    L = list(input().split())
    l.append(l[1:]) 
s=list(input().split())
c=0
for i in range(2**N):
    for j in range(M):
        a = 0
        for k range(N):
            if ((i >>k) == 1 and k+1 in l[j]:
                a += 1
        if a%2 == s[j]:
            d *= 1
        else:
            d *= 0
    if d == 1:
        c += 1
print(c)