n,m=map(int,input().split())
S=[list(map(int,input().split()))[1:] for _ in range(m)]
P=list(map(int,input().split()))

cnt=0
for i in range(2**n):
    Q=0
    switch=set([i+1 for i,j in enumerate(format(i,"b").zfill(n)[::-1]) if j == '1'])
    for k,j in enumerate(S):
        if len(switch&set(j))%2==P[k]:
            Q+=1
    if Q==m:
        cnt+=1

print(cnt)