import numpy as np



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

ks=np.array([[int(i) for i in input().split()] for _ in range(M)])

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



ans=0



for i in range(2**N):



    # swにスイッチのオンオフを記録

    sw=[0]*N

    for j in range(N):

        if (i>>j)&1:

            sw[j]=1



    count=0

    for denkyu_no in range(M):

        if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:

            count +=1



    if count==M:

        ans+=1

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

ks = [[int(i) for i in input().split()] for _ in range(m)]

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



ans=0

for i in range(2**n):

    sw=[]

    on=0

    for j in range(n):

        sw.append(i>>j & 1)

    for k in range(m):

        if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:

            on +=1

    if on==m:

        ans +=1

print(ans)

import numpy as np

N, M = list(map(int, input().split()))
ks = np.array([[int(i) for i in input().split()] for _ in range(M)])
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    # swにスイッチのオンオフを記録
    sw = [0] * N
    for j in range(N):
        if (i >> j) & 1:
            sw[j] = 1
    count = 0
    for denkyu_no in range(M):
        if (
            sum([sw[ks[denkyu_no][j + 1] - 1] for j in range(ks[denkyu_no][0])]) % 2
            == p[denkyu_no]
        ):
            count += 1
    if count == M:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    sw = []
    on = 0
    for j in range(n):
        sw.append(i >> j & 1)
    for k in range(m):
        if (sum([sw[ks[k][j + 1] - 1] for j in range(ks[k][0])])) % 2 == p[k]:
            on += 1
    if on == m:
        ans += 1
print(ans)

-import numpy as np - -N, M = list(map(int, input().split())) -ks = np.array([[int(i) for i in input().split()] for _ in range(M)]) +n, m = list(map(int, input().split())) +ks = [[int(i) for i in input().split()] for _ in range(m)] -for i in range(2**N): -    # swにスイッチのオンオフを記録 -    sw = [0] * N -    for j in range(N): -        if (i >> j) & 1: -            sw[j] = 1 -    count = 0 -    for denkyu_no in range(M): -        if ( -            sum([sw[ks[denkyu_no][j + 1] - 1] for j in range(ks[denkyu_no][0])]) % 2 -            == p[denkyu_no] -        ): -            count += 1 -    if count == M: +for i in range(2**n): +    sw = [] +    on = 0 +    for j in range(n): +        sw.append(i >> j & 1) +    for k in range(m): +        if (sum([sw[ks[k][j + 1] - 1] for j in range(ks[k][0])])) % 2 == p[k]: +            on += 1 +    if on == m: