n, m = map(int, input().split())
s = []
for _ in range(m):
    _, *ss = map(int, input().split())
    s.append(ss)
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    for j in range(m):
        tmp = 0
        for k in s[j]:
            tmp += i>>(k-1)&1
        if tmp%2!=p[j]:
            break
    else:
        ans += 1
print(ans)