n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

sw = [i + 1 for i in range(n)]

t_on = []
for i in range(2 ** n):
    on = []
    for j in range(n):
        if (i>>j) & 1:
            on.append(sw[j])

    t_on.append(on)

ans = 0
for i in range(1, len(t_on)):
    for j in range(m):
        c = set(t_on[i]) & set(ks[j][1:])
        # print(ks[j][1:], t_on[i], c, len(c), p[j])
        if len(c) % 2 != p[j]: break
    else:
        ans += 1

print(ans)