from itertools import product
N, M = map(int, input().split())
S = []
for m in range(M):
    s = list(map(int, input().split()))
    S.append(s[1:])
    
p = list(map(int, input().split()))

ans = 0
for c in product([0, 1], repeat = N):
    ok = True
    for m in range(M):
        sm = 0
        for k in S[m]:
            sm += c[k - 1]
        if sm % 2 != p[m]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)
 from itertools import product N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = [] S [] for m in range(M):
    s = list(map(int, input().split()))
    S.append(s[1:])
     m range(M) range M s = list(map(int, input().split())) s list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split S.append(s[1:]) S.append S append s[1:] s 1: 1 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for c in product([0, 1], repeat = N):
    ok = True
    for m in range(M):
        sm = 0
        for k in S[m]:
            sm += c[k - 1]
        if sm % 2 != p[m]:
            ok = False
            break
    if ok:
        ans += 1 c product([0, 1], repeat = N) product [0, 1] 0 1 repeat = N repeat N ok = True ok True for m in range(M):
        sm = 0
        for k in S[m]:
            sm += c[k - 1]
        if sm % 2 != p[m]:
            ok = False
            break
     m range(M) range M sm = 0 sm 0 for k in S[m]:
            sm += c[k - 1]
         k S[m] S m sm += c[k - 1] sm c[k - 1] c k - 1 k 1 if sm % 2 != p[m]:
            ok = False
            break
     sm % 2 != p[m] sm % 2 sm 2 p[m] p m ok = False ok False break if ok:
        ans += 1 ok ans += 1 ans 1 print(ans) print ans sm = 0 0 sm ok = False False ok ok = True True ok M = map(int, input().split()) map(int, input().split()) M sm += c[k - 1] c[k - 1] sm N, M = map(int, input().split()) map(int, input().split()) N s = list(map(int, input().split())) list(map(int, input().split())) s ans += 1 1 ans p = list(map(int, input().split())) list(map(int, input().split())) p S = [] [] S ans = 0 0 ans
from itertools import product
N, M = map(int, input().split())
S = []
for m in range(M):
    s = list(map(int, input().split()))
    S.append(s[1:])
    
p = list(map(int, input().split()))

ans = 0
for c in product([0, 1], repeat = N):
    ok = True
    for m in range(M):
        sm = 0
        for k in S[m]:
            sm += c[k - 1]
        if sm % 2 != p[m]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)

