n,m = map(int,input().split())
s = [list(map(int,input().split()))[1:]for i in range(m)]
p = list(map(int,input().split()))
form = "0"+str(n)+"b"
ans = 0
for i in range(2**n):
    ptn = format(i,form)
    light = True
    for j in range(m):
        s = sum(int(ptn[k-1])for k in s[j])
        if s%2 != p[j]:
            light = False
    if light == True:
        ans += 1
print(ans)