n, m = map(int, input().split())
lig = []

def decli(n):
    return n - 1
for i in range(m):
    s = list(map(int, input().split()))
    s = s[1:]
    s = list(map(decli, s))
    lig.append(s)
p = list(map(int, input().split()))

cnt = 0
for i in range(2 ** n):
    switch = []
    tmp = i
    for j in range(n):
        switch.append(tmp % 2)
        tmp //= 2
    all_flg = 1
    for lig_no in range(m):
        flg = 0
        for j in range(len(lig[lig_no])):
            flg ^= switch[j]
        if flg != p[lig_no]:
            all_flg = 0
            break
    if all_flg == 1:
        cnt += 1

print(cnt)
