N, M = map(int, input().split())
s2 = []
for _ in range(M):
    s = list(map(int, input().split()))
    del s[0]
    s2.append(s)
p = list(map(int, input().split()))
 
ans = 0
for i in range(2**N):
    judge = True
    for g in range(len(s2)):
        for j in range(M-1):
            count = 0
            s3 = s2[g][j]
            if i >> (s3-1) & 1:
                count += 1
            if count % 2 != p[g]:
                judge = False
    if judge:
        ans += 1
print(ans)