N, M = list(map(int, input().split()))
s = []
for i in range(M):
    tmp = list(map(int, input().split()))
    t = 0
    for j in tmp[1:]:
        t += 1 << (j - 1)
    s.append(t)
p = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    for x, y in zip(s, p):
        t = i & x
        c = bin(t).count('1') % 2
        if c == y:
            ans +=1
print(ans)
