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

s = []

for _ in range(m):

    _, *args = list(map(int, input().split()))

    s.append(args)

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

ans = 0

for i in range(2 ** n):

    for j in range(m):

        sw = 0

        for k in range(n):

            if (i >> k) & 1 and k + 1 in s[j]:

                sw += 1

        if sw % 2 != p[j]:

            break

    else:

        ans += 1

print(ans)

from itertools import product



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

ks = []

for i in range(m):

    k, *arg = list(map(int, input().split()))

    ks.append((k, arg))

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



res = 0

for pattern in product((0, 1), repeat=n):

    for i in range(m):

        cnt = 0

        k, s = ks[i]

        for j in range(k):

            cnt += pattern[s[j] - 1]

        if cnt % 2 != p[i]:

            break

    else:

        res += 1



print(res)
n, m = list(map(int, input().split()))
s = []
for _ in range(m):
    _, *args = list(map(int, input().split()))
    s.append(args)
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    for j in range(m):
        sw = 0
        for k in range(n):
            if (i >> k) & 1 and k + 1 in s[j]:
                sw += 1
        if sw % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)

from itertools import product

n, m = list(map(int, input().split()))
ks = []
for i in range(m):
    k, *arg = list(map(int, input().split()))
    ks.append((k, arg))
p = list(map(int, input().split()))
res = 0
for pattern in product((0, 1), repeat=n):
    for i in range(m):
        cnt = 0
        k, s = ks[i]
        for j in range(k):
            cnt += pattern[s[j] - 1]
        if cnt % 2 != p[i]:
            break
    else:
        res += 1
print(res)

+from itertools import product + -s = [] -for _ in range(m): -    _, *args = list(map(int, input().split())) -    s.append(args) +ks = [] +for i in range(m): +    k, *arg = list(map(int, input().split())) +    ks.append((k, arg)) -ans = 0 -for i in range(2**n): -    for j in range(m): -        sw = 0 -        for k in range(n): -            if (i >> k) & 1 and k + 1 in s[j]: -                sw += 1 -        if sw % 2 != p[j]: +res = 0 +for pattern in product((0, 1), repeat=n): +    for i in range(m): +        cnt = 0 +        k, s = ks[i] +        for j in range(k): +            cnt += pattern[s[j] - 1] +        if cnt % 2 != p[i]: -        ans += 1 -print(ans) +        res += 1 +print(res)