import numpy as np
N, M = map(int, input().split())
mat = np.zeros(N*M).reshape(M, N)

for i in range(M):
    k = list(map(int, input().split()))
    for j in k[1:]:
        mat[i-1, j-1] += 1
p = list(map(int, input().split()))

def two(x):
    a = np.zeros(N)
    for i in range(11):
        if x == 0:
            break
        elif x % 2 == 0:
            x = x // 2
        else:
            a[i] += 1
            x = x // 2
    return a

flag = 0
for i in range(2**N):
    a = two(i)
    mat2 = mat * a
    for j in range(M):
        if np.sum(mat2[j]) % 2 != p[j]:
            break
        if j == M-1:
            flag += 1

print(flag)
