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

a=0
for n in range(2**N):
    s_count=0
    flgs=[]
    for j,s in enumerate(S):
        count=0
        for t in s:
            if n &(1<<t):
               count|=1<<t
        s_count^=count
        if bin(s_count).count("1")%2==P[j]:
           flgs.append(True) 
        else:
            flgs.append(False)
    if all(flgs):
        a+=1
print(a)