N,M = map(int,input().split())
ks = [list(map(int,input().split())) for _ in [0]*M]
*p,= map(int,input().split())
ans = 0
for i in range(1<<N):
    S = [(i&(1<<j))>0 for j in range(N)]
    tmp = 0
    for j,ks1 in enumerate(ks):
        k,*s = ks1
        tmp = sum(S[c-1] for c in s)
        if tmp%2 != p[j]:break
    else:
        ans+=1
print(ans)