N, M = map(int, input().split())
S = []
for _ in range(M):
    tmp = list(map(int, input().split()))
    k = tmp[0]
    s = tmp[1:]
    S.append(s)

P = list(map(int, input().split()))[::-1]
ans = 0

for i in range(2 ** N):
    on = []
    for j in range(N):
        if i >> j & 1 == 1:
            on.append(N - j)
    for i in range(M):
        if len(set(on) & set(S[i])) % 2 != P[i]:
            break
    else:
        ans += 1

print(ans)      