def bitcount(bit):
    return bin(bit).count("1")

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

for i in range(m):
    s.append( list(map(int,input().split())) )
p = list(map(int,input().split()))

for i in s:
    mask = 0
    for j in i[1:]:
        mask |= 1<<(j-1)        
    kmask.append(mask)

result = 0
for i in range(1,1<<n):
    ok = True
    for mask,odd in zip(kmask,p):
        bc = bitcount(i&mask)
        if((bc&1)!=odd):
            ok = False
            break
    if ok:
        result += 1

print(result)