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 i, ksi in enumerate(ks):
        tmp = sum(pat[ksi[j + 1] - 1] for j in range(ksi[0]))
        if  tmp % 2 != p[i]:
            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 i, ksi in enumerate(ks):
        tmp = sum(pat[ksi[j + 1] - 1] for j in range(ksi[0]))
        if  tmp % 2 != p[i]:
            break
    else:
        cnt += 1 pat product([0, 1], repeat=n) product [0, 1] 0 1 repeat=n repeat n for i, ksi in enumerate(ks):
        tmp = sum(pat[ksi[j + 1] - 1] for j in range(ksi[0]))
        if  tmp % 2 != p[i]:
            break
    else:
        cnt += 1 i ksi enumerate(ks) enumerate ks tmp = sum(pat[ksi[j + 1] - 1] for j in range(ksi[0])) tmp sum(pat[ksi[j + 1] - 1] for j in range(ksi[0])) sum pat[ksi[j + 1] - 1] pat ksi[j + 1] - 1 ksi[j + 1] ksi j + 1 j 1 1 if  tmp % 2 != p[i]:
            break
     tmp % 2 != p[i] tmp % 2 tmp 2 p[i] p i break cnt += 1 cnt 1 print(cnt) print cnt n, m = map(int, input().split()) map(int, input().split()) n p = list(map(int, input().split())) list(map(int, input().split())) p tmp = sum(pat[ksi[j + 1] - 1] for j in range(ksi[0])) sum(pat[ksi[j + 1] - 1] for j in range(ksi[0])) tmp ks = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] ks m = map(int, input().split()) map(int, input().split()) m cnt = 0 0 cnt cnt += 1 1 cnt
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 i, ksi in enumerate(ks):
        tmp = sum(pat[ksi[j + 1] - 1] for j in range(ksi[0]))
        if  tmp % 2 != p[i]:
            break
    else:
        cnt += 1
print(cnt)
