n, m = map(int, input().split())
k = []
for i in range(m):
    s = list(map(int, input().split()))
    k.append(s[1:])
p = list(map(int, input().split()))

ans = 0
for patterns in range(2**n):
    ptn = bin(patterns)[2:].rjust(n, '0')
    # print(ptn)
    for i in range(m):
        num = 0
        for j in range(len(k[i])):
            num += int(ptn[k[i][j] - 1])
        if (p[i] == 0 and (num+p[i]) % 2 == 1) or (p[i] == 1 and (num+p[i]) % 2 == 0):
            break
        ans += 1
print(2**n - ans)
