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

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

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

ans=0

for i in range(2**n):

    result=[0]*m

    for j in range(n):

        if (i>>j)&1:

            for k in range(m):

              if j+1 in switch_list[k][1:]:

                  result[k]+=1

    for l in range(m):

        if (result[l]%2)!=p[l]:

            break

    else:

        ans+=1

print(ans)
from itertools import product

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

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

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

count=0

for i in product([0,1],repeat=n):

    for j in range(m):

        

        temp=0

        for k in range(ks[j][0]):

            if i[ks[j][k+1]-1]==1:

                temp+=1

        if temp%2!=p[j]:

            break

    else: 

        count+=1

print(count)

n, m = list(map(int, input().split()))
switch_list = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    result = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                if j + 1 in switch_list[k][1:]:
                    result[k] += 1
    for l in range(m):
        if (result[l] % 2) != p[l]:
            break
    else:
        ans += 1
print(ans)

from itertools import product

n, m = list(map(int, input().split()))
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
count = 0
for i in product([0, 1], repeat=n):
    for j in range(m):
        temp = 0
        for k in range(ks[j][0]):
            if i[ks[j][k + 1] - 1] == 1:
                temp += 1
        if temp % 2 != p[j]:
            break
    else:
        count += 1
print(count)

+from itertools import product + -switch_list = [list(map(int, input().split())) for _ in range(m)] +ks = [list(map(int, input().split())) for _ in range(m)] -ans = 0 -for i in range(2**n): -    result = [0] * m -    for j in range(n): -        if (i >> j) & 1: -            for k in range(m): -                if j + 1 in switch_list[k][1:]: -                    result[k] += 1 -    for l in range(m): -        if (result[l] % 2) != p[l]: +count = 0 +for i in product([0, 1], repeat=n): +    for j in range(m): +        temp = 0 +        for k in range(ks[j][0]): +            if i[ks[j][k + 1] - 1] == 1: +                temp += 1 +        if temp % 2 != p[j]: -        ans += 1 -print(ans) +        count += 1 +print(count)