from itertools import product

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

cnt = 0
for pat in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        tmp = sum(pat[ksij - 1] for ksij in ksi[1:])
        if  tmp % 2 != pi:
            break
    else:
        cnt += 1
print(cnt) from itertools import product n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ks = [list(map(int, input().split())) for _ in range(m)] ks [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for pat in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        tmp = sum(pat[ksij - 1] for ksij in ksi[1:])
        if  tmp % 2 != pi:
            break
    else:
        cnt += 1 pat product([0, 1], repeat=n) product [0, 1] 0 1 repeat=n repeat n for ksi, pi in zip(ks, p):
        tmp = sum(pat[ksij - 1] for ksij in ksi[1:])
        if  tmp % 2 != pi:
            break
    else:
        cnt += 1 ksi pi zip(ks, p) zip ks p tmp = sum(pat[ksij - 1] for ksij in ksi[1:]) tmp sum(pat[ksij - 1] for ksij in ksi[1:]) sum pat[ksij - 1] pat ksij - 1 ksij 1 if  tmp % 2 != pi:
            break
     tmp % 2 != pi tmp % 2 tmp 2 pi break cnt += 1 cnt 1 print(cnt) print cnt n, m = map(int, input().split()) map(int, input().split()) n tmp = sum(pat[ksij - 1] for ksij in ksi[1:]) sum(pat[ksij - 1] for ksij in ksi[1:]) tmp p = list(map(int, input().split())) list(map(int, input().split())) p cnt += 1 1 cnt ks = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] ks cnt = 0 0 cnt m = map(int, input().split()) map(int, input().split()) m
from itertools import product

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

cnt = 0
for pat in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        tmp = sum(pat[ksij - 1] for ksij in ksi[1:])
        if  tmp % 2 != pi:
            break
    else:
        cnt += 1
print(cnt)
