import itertools
N, M = map(int, raw_input().split())
data = [map(int, raw_input().split()) for i in range(M)]
p = map(int, raw_input().split())
k = [data[i][0] for i in range(M)]
s = [data[i][1:] for i in range(M)]

candidate = []

def Check(switches):
    for i in range(M):
        if (sum([switches[s[i][j] - 1] for j in range(k[i])]) % 2) != p[i]:
            return 0
    return 1

print sum(Check(switches) for switches in itertools.product([0, 1], repeat=N))
