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

cnt=0

for i in range(2**N):
    for k in range(M):
        tmp=0
        for j in range(N):
            if ((i >> j) & 1) and j+1 in s[k]:
                tmp+=1
        if tmp%2!=p[k]:
            break
    else:
        cnt+=1
print(cnt)