import itertools as it

n, m = map(int, input().split())

s = []

for i in range(m):

    k, *temp = map(int, input().split())

    s.append(set(temp))

p = list(map(int, input().split()))

ans = 0

for i in range(1, n + 1):

    for comb in it.combinations(list(range(1, n + 1)), i):

        flag = [False] * m

        for j in range(m):

            if sum([c in s[j] for c in comb]) % 2 == p[j]:
                flag[j] = True

        if all(flag):
            ans += 1

print(ans)