N, M = list(map(int, input().split()))

s = [0] * M

for i in range(M):

    s[i] = list(map(int, input().split()))[1:]

    s[i] = [v - 1 for v in s[i]]



p = list(map(int, input().split()))



ans = 0

for i in range(1 << N):

    all_lit = True

    for j in range(M):

        n = 0

        for k in s[j]:

            n += bool(i & (1 << k))

        if n % 2 != p[j]:

            all_lit = False

            break

    ans += all_lit



print(ans)

import sys



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60



N, M = list(map(int, readline().split()))

S = [[] for _ in range(M)]

for i in range(M):

    _, *S[i] = [int(s) - 1 for s in readline().split()]

P = list(map(int, readline().split()))



ans = 0

for i in range(1 << N):

    switches = [bool(i & (1 << j)) for j in range(N)]

    all_lit = True

    for j in range(M):

        if sum(switches[k] for k in S[j]) % 2 != P[j]:

            all_lit = False

            break

    if all_lit:

        ans += 1



print(ans)

N, M = list(map(int, input().split()))
s = [0] * M
for i in range(M):
    s[i] = list(map(int, input().split()))[1:]
    s[i] = [v - 1 for v in s[i]]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    all_lit = True
    for j in range(M):
        n = 0
        for k in s[j]:
            n += bool(i & (1 << k))
        if n % 2 != p[j]:
            all_lit = False
            break
    ans += all_lit
print(ans)

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
N, M = list(map(int, readline().split()))
S = [[] for _ in range(M)]
for i in range(M):
    _, *S[i] = [int(s) - 1 for s in readline().split()]
P = list(map(int, readline().split()))
ans = 0
for i in range(1 << N):
    switches = [bool(i & (1 << j)) for j in range(N)]
    all_lit = True
    for j in range(M):
        if sum(switches[k] for k in S[j]) % 2 != P[j]:
            all_lit = False
            break
    if all_lit:
        ans += 1
print(ans)

-N, M = list(map(int, input().split())) -s = [0] * M +import sys + +read = sys.stdin.read +readline = sys.stdin.readline +readlines = sys.stdin.readlines +sys.setrecursionlimit(10**9) +INF = 1 << 60 +N, M = list(map(int, readline().split())) +S = [[] for _ in range(M)] -    s[i] = list(map(int, input().split()))[1:] -    s[i] = [v - 1 for v in s[i]] -p = list(map(int, input().split())) +    _, *S[i] = [int(s) - 1 for s in readline().split()] +P = list(map(int, readline().split())) +    switches = [bool(i & (1 << j)) for j in range(N)] -        n = 0 -        for k in s[j]: -            n += bool(i & (1 << k)) -        if n % 2 != p[j]: +        if sum(switches[k] for k in S[j]) % 2 != P[j]: -    ans += all_lit +    if all_lit: +        ans += 1