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

ans = 0
for b in range(2**N):
    for s,p in zip(S,P):
        c = 0
        for t in s:
            if b&(1<<(t-1)): c += 1
        if c%2 != p:
            break
    else:
        ans += 1
print(ans)