import itertools

n, m = 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 itertools.product([0, 1], repeat=n):
    for j in range(m):
        s = 0
        for k in range(ks[j][0]):
            if ks[j][k]-1 == i[k]:
                s += 1
        if s % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)