import itertools

N,M = map(int,input().split())

sw = [[] for _ in range(M)]
for i in range(M):
    sw[i] = list(map(int,input().split()))

P = list(map(int,input().split()))
ans = 0
for tpl in itertools.product([0,1], repeat=N):
    bl = True
    for i in range(M):
        s = sum([tpl[j-1] for j in sw[i]])
        if (s-P[i])%2 == 1:
            bl = False
            break
    if bl:
        ans += 1

print(ans)