from functools import reduce
from operator import add
n, m = [int(i) for i in input().split()]

lamp = [None] * m
for i in range(m):
    tmp = ['0'] * n
    for k in [int(j) for j in input().split()][1:]:
        tmp[n-k] = '1'
    lamp[i] = int(''.join(tmp), 2)

p = [int(i) for i in input().split()]

ans = 0
for i in range(1, 2**n):
    if all([bin(i & lamp[j]).count("1") % 2 == p[j] for j in range(m)]):
        ans += 1

print(ans)
