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

ans = 0
for i in range(1<<N):
    for j in range(M):
        cnt = 0
        for s in S[j][1:]:
            if i >> s & 1: cnt += 1
        if cnt%2 != P[j]: break
    else:
        ans += 1

print(ans)