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
    pattern=[i for i in range(n) if n & (1<<i)]
    for j,s in enumerate(S):
        on=0
        for t in s:
            if t-1 in pattern:
                on|=1<<t-1
        s_count^=on
        if bin(s_count).count("1")%2!=P[j]:
            break
    else:
        a+=1
print(a)