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

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

p=list(map(int,input().split()))
#以上入力

def binary_ume(N,K):  #Nを2進数表示し、K桁まで0埋めする
    A = []
    while N >= 2:
        A.append(N%2)
        N = N//2
    A.append(N)
    while len(A) < K:
        A.append(0)
    return A

ans = 0
print(k,p)

for i in range(m):
    for j in range(1,len(k[i])):
        k[i][j] -= 1

for i in range(2**n):
    switch = binary_ume(i,n)  #スイッチの推し方全部見る
    all_on = 1  #何かひとつでもダメならすぐ切る
    for j in range(m):
        if sum(switch[l] for l in k[j][1:])%2 != p[j]:
            all_on = 0
            break
    if all_on == 1:
        ans += 1

print(ans)