N, M = [int(i) for i in input().split()]
K = []
S = []
for _ in range(M):
    k, *s = [int(i)-1 for i in input().split()]
    K.append(k)
    S.append(set(s))

P = [int(i) for i in input().split()]

def judge(x):
    for i in range(M):
        if not((k-len(S[i]-x)) % 2 == P[i]):
            return False
    return True

res = 0
for bit in range(2**N):
    on = set()
    for i in range(N):
        if bit & (2**i):
            on.add(i)
    if judge(on):
        res += 1

print(res)