f = lambda : list(map(int, input().split()))



n, m = f()

ll = [[0]*n for i in range(m)]

for i in range(m):

  _, *t = f()

  for j in t:

    ll[i][j-1] = 1

lp = list(f())



import itertools as it

ans = 0



for p in it.product([0,1], repeat=n):

  if lp == [sum(a*b for a, b in zip(p,l))%2 for l in ll]:

    ans += 1



print(ans)
f=lambda:list(map(int,input().split()))

n,m=f()

ll=[[0]*n for _ in range(m)]

for l in ll:

  k,*s=f()

  for i in s: l[i-1]=1

p=list(f())

import itertools as it

print((sum(all(sum(a*b for a,b in zip(l,t))%2==p[i] for i,l in enumerate(ll)) for t in it.product([0,1],repeat=n))))
f = lambda: list(map(int, input().split()))
n, m = f()
ll = [[0] * n for i in range(m)]
for i in range(m):
    _, *t = f()
    for j in t:
        ll[i][j - 1] = 1
lp = list(f())
import itertools as it

ans = 0
for p in it.product([0, 1], repeat=n):
    if lp == [sum(a * b for a, b in zip(p, l)) % 2 for l in ll]:
        ans += 1
print(ans)

f = lambda: list(map(int, input().split()))
n, m = f()
ll = [[0] * n for _ in range(m)]
for l in ll:
    k, *s = f()
    for i in s:
        l[i - 1] = 1
p = list(f())
import itertools as it

print(
    (
        sum(
            all(sum(a * b for a, b in zip(l, t)) % 2 == p[i] for i, l in enumerate(ll))
            for t in it.product([0, 1], repeat=n)
        )
    )
)

-ll = [[0] * n for i in range(m)] -for i in range(m): -    _, *t = f() -    for j in t: -        ll[i][j - 1] = 1 -lp = list(f()) +ll = [[0] * n for _ in range(m)] +for l in ll: +    k, *s = f() +    for i in s: +        l[i - 1] = 1 +p = list(f()) -ans = 0 -for p in it.product([0, 1], repeat=n): -    if lp == [sum(a * b for a, b in zip(p, l)) % 2 for l in ll]: -        ans += 1 -print(ans) +print( +    ( +        sum( +            all(sum(a * b for a, b in zip(l, t)) % 2 == p[i] for i, l in enumerate(ll)) +            for t in it.product([0, 1], repeat=n) +        ) +    ) +)