import numpy as np
n, m = map(int, input().split())
light = [
    tuple(map(int, input().split())) for i in range(m)
]
light = sorted(light, key=lambda x: x[0])
p = tuple(map(int, input().split()))

ans = 0
for i in range(2**n):
    x = str(bin(i))[2:]
    if len(x) < n:
        x = "0" * (n - len(x)) + x
    a = 1
    for j in range(m):
        check = 0
        for k in light[j][1:]:
            if x[k-1] == "1":
                check += 1
        if check % 2 == p[j]:
            pass
        else:
            a = 0
            break
    if a:
        ans += 1
print(ans)
