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

# m行分配列に放り込む
KS_lis = [list(map(int, input().split())) for _ in range(M)]

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

KS = []
bin_s = ''
ans = 0

for i in range(2**N):

    for j in range(M):
        Z = [0]*N
        KS = KS_lis[j]
        K = KS[0]
        S = KS[1:]

        for l in range(K):
            Z[N-S[l-1]] += 1

        bin_s = ''

        for x in Z:
            bin_s += str(x)

        if bin(i & int(bin_s)).count("1") % 2 != P[j]:
            break
    else:
        ans += 1

print(ans)
