import numpy as np

 

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

array = np.zeros([M, N])

for i in range(M):

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

    for j in l[1:]:

        array[i, j-1] = 1

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

count = 0

for i in range(1<<N):

    array_i = array.copy()

    for j in range(N):

        if i&(1<<j):

            array_i[:, j-1] = 0

    if sum(array_i.sum(1)%2 == p)==M:

        count += 1

print(count)
import itertools

n,m=list(map(int, input().split()))

k=[list(map(int, input().split())) for i in range(m)]

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

bit=list(itertools.product([0,1], repeat=n))

ans=0

for i in bit:

  cnt=0

  for j in range(m):

    cnt2=0

    for l in range(1,k[j][0]+1):

      if i[k[j][l]-1]==1:

        cnt2+=1

    if cnt2%2==p[j]:

      cnt+=1

  if cnt==m:

    ans+=1

print(ans)
import numpy as np

N, M = list(map(int, input().split()))
array = np.zeros([M, N])
for i in range(M):
    l = list(map(int, input().split()))
    for j in l[1:]:
        array[i, j - 1] = 1
p = np.array(list(map(int, input().split())))
count = 0
for i in range(1 << N):
    array_i = array.copy()
    for j in range(N):
        if i & (1 << j):
            array_i[:, j - 1] = 0
    if sum(array_i.sum(1) % 2 == p) == M:
        count += 1
print(count)

import itertools

n, m = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
bit = list(itertools.product([0, 1], repeat=n))
ans = 0
for i in bit:
    cnt = 0
    for j in range(m):
        cnt2 = 0
        for l in range(1, k[j][0] + 1):
            if i[k[j][l] - 1] == 1:
                cnt2 += 1
        if cnt2 % 2 == p[j]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)

-import numpy as np +import itertools -N, M = list(map(int, input().split())) -array = np.zeros([M, N]) -for i in range(M): -    l = list(map(int, input().split())) -    for j in l[1:]: -        array[i, j - 1] = 1 -p = np.array(list(map(int, input().split()))) -count = 0 -for i in range(1 << N): -    array_i = array.copy() -    for j in range(N): -        if i & (1 << j): -            array_i[:, j - 1] = 0 -    if sum(array_i.sum(1) % 2 == p) == M: -        count += 1 -print(count) +n, m = list(map(int, input().split())) +k = [list(map(int, input().split())) for i in range(m)] +p = list(map(int, input().split())) +bit = list(itertools.product([0, 1], repeat=n)) +ans = 0 +for i in bit: +    cnt = 0 +    for j in range(m): +        cnt2 = 0 +        for l in range(1, k[j][0] + 1): +            if i[k[j][l] - 1] == 1: +                cnt2 += 1 +        if cnt2 % 2 == p[j]: +            cnt += 1 +    if cnt == m: +        ans += 1 +print(ans)