n, m = map(int,input().split())
sw =[tuple(map(int,input().split())) for i in range(n)]
p = list(map(int,input().split()))

ans = 0
for b in range(1<<n):
    for i in range(m):
        c = 0
        for s in sw[i][1:]:
            if b &(1<<(s-1)):
                c += 1
        if c % 2 != p[i]:break
    else:
        ans +=1
print(ans)