import itertools
N, M = [int(_) for _ in input().split()]
KS = [[int(_) - 1 for _ in input().split()] for _ in range(M)]
P = [int(_) for _ in input().split()]
ans = 0
for switches in itertools.product(range(2), repeat=N):
    f = all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS))
    ans += f
print(ans) import itertools itertools int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ N, M = [int(_) for _ in input().split()] N [int(_) for _ in input().split()] M [int(_) - 1 for _ in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(_) - 1 for _ in input().split()] KS = [[int(_) - 1 for _ in input().split()] for _ in range(M)] KS [[int(_) - 1 for _ in input().split()] for _ in range(M)] int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ P = [int(_) for _ in input().split()] P [int(_) for _ in input().split()] ans = 0 ans 0 for switches in itertools.product(range(2), repeat=N):
    f = all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS))
    ans += f switches itertools.product(range(2), repeat=N) itertools.product itertools product range(2) range 2 repeat=N repeat N f = all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS)) f all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS)) all sum(switches[s] for s in ks[1:]) % 2 == P[i] sum(switches[s] for s in ks[1:]) % 2 sum(switches[s] for s in ks[1:]) sum switches[s] switches s 2 P[i] P i ans += f ans f print(ans) print ans M = [int(_) for _ in input().split()] [int(_) for _ in input().split()] M KS = [[int(_) - 1 for _ in input().split()] for _ in range(M)] [[int(_) - 1 for _ in input().split()] for _ in range(M)] KS N, M = [int(_) for _ in input().split()] [int(_) for _ in input().split()] N P = [int(_) for _ in input().split()] [int(_) for _ in input().split()] P ans = 0 0 ans f = all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS)) all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS)) f ans += f f ans
import itertools
N, M = [int(_) for _ in input().split()]
KS = [[int(_) - 1 for _ in input().split()] for _ in range(M)]
P = [int(_) for _ in input().split()]
ans = 0
for switches in itertools.product(range(2), repeat=N):
    f = all(
        sum(switches[s] for s in ks[1:]) % 2 == P[i]
        for i, ks in enumerate(KS))
    ans += f
print(ans)
