rom itertools import product
 
n, m = map(int, input().split())
k = []
s = []
for i in range(m):
    tmp = list(map(int, input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int, input().split()))
 
ans = 2 ** n
for prod in (product([0, 1], repeat=n)):
    for i in range(m):
        tmp = 0
        for j in s[i]:
            tmp += prod[j - 1]
        if (tmp % 2 != p[i]):
            ans -= 1
            break
print(ans)