from itertools import combinations
from collections import defaultdict
n, m = map(int, input().split())
switch = defaultdict(list)
for i in range(m):
    s = list(map(int, input().split()))[1:]
    switch[i] = s
p = list(map(int, input().split()))

output = 0
for h in range(2**n):
    flag = 1
    padding = f'0{n}b'
    bit = format(h, padding)
    for i, v in enumerate(p):
        cnt = 0
        for j in switch[i]:
            if bit[j-1] == '1':
                cnt += 1
        if cnt % 2 != v:
            flag = 0
    if flag == 1:
        output += 1
print(output)
