n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    s = 0
    for ki, j in enumerate(k):
        count = 0
        for t in j[1:]:
            if i & t == t:
                count += 1
        if count % 2 != p[ki]:
            s += 1
    if s == m:
        ans +=1 
print(ans)
