n, m = map(int, input().split())
k_s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

s = bin(0)[2:].zfill(n)
ans = 0

for i in range(2 ** n):
    cnt = 0
    for j in range(m):
        on = 0
        for k in range(k_s[j][0]):
            if s[k_s[j][k] - 1] == '1':
                on += 1
            if k == k_s[j][0] - 1:
                if on % 2 == p[j] and on != 0:
                    cnt += 1
    if cnt == m:
        ans += 1
    s = bin(int(s, 2) + 1)[2:].zfill(n)
print(ans)