N, M = list(map(int, input().split()))
s = [sum([2 ** (i - 1) for i in list(map(int, input().split()))[1:]]) for _ in range(M)]
p = list(map(int, input().split()))

ans, n = 0, 2 ** N
for i in range(n):
    for s_, p_ in zip(s, p):
        if bin(i & s_).count("1") % 2 != p_:
            break
    else:
        ans += 1
        
print(ans)