N, M = list(map(int, input().split()))
l = []
for i in range(M):
    ks = list(map(int, input().split()))
    k, s = ks[0], ks[1:]
    l.append(s)
    
p = list(map(int, input().split()))

ans = 0
for j in range(2**N):
    n = 0  
    for m in range(M):
        t = 0
        for sw in l[m]:
            if (j>>(sw-1)&1):
                print((j>>(sw-1)&1))
                t += 1
        if t%2 == p[m]:
            n += 1
        else:
            break
    if n == M:
        ans += 1
print(ans)