n, m = map(int, input().split())
s = [sum(list(map(lambda x: 2**(int(x) - 1), input().split()[1:]))) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    cnt = 0
    for j in range(m):
        if sum([((i & s[j]) >> k) % 2 for k in range(n)]) % 2 == p[j]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)