n, m = map(int, input().split())
a = [0] * n

for i in range(m):
    k, *s = list(map(int, input().split()))
    for j in range(k):
        a[s[j] - 1] |= 1 << i

p = sum(list(map(int, input().split())))

ans = 0
for s in range(1 << n):
    t = 0
    for i in range(n):
        if s >> i & 1:
            t ^= a[i]
    if t == p:
        ans += 1
print(ans)
