from numpy import*

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

s=[[int(j) for j in input().split()][1:] for i in range(m)]

p=[int(i) for i in input().split()]

a=0

for i in range(2**n):

    b=array([(i>>j)&1 for j in range(n)])

    if [sum(b[array(k)-1])%2 for k in s]==p:

      a+=1

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

k = []



# s[i] := i番目のスイッチについている電球群

s = [[] for _ in range(n)]

for i in range(m):

  temp = [int(i) for i in input().split()]

  k.append(temp[0])

  for j in temp[1:]:

    s[j-1].append(i)



p = [int(i) for i in input().split()]

count = 0

for i in range(2 ** n):

  state = [0 for _ in range(m)]

  for j in range(n):

    # スイッチがついていたら、つながっている電球に+1する

    if (i >> j) & 1:

      for k in s[j]:

        state[k] = (state[k] + 1) % 2

  if state == p:

    count += 1

print(count)

from numpy import *

n, m = list(map(int, input().split()))
s = [[int(j) for j in input().split()][1:] for i in range(m)]
p = [int(i) for i in input().split()]
a = 0
for i in range(2**n):
    b = array([(i >> j) & 1 for j in range(n)])
    if [sum(b[array(k) - 1]) % 2 for k in s] == p:
        a += 1
print(a)

n, m = list(map(int, input().split()))
k = []
# s[i] := i番目のスイッチについている電球群
s = [[] for _ in range(n)]
for i in range(m):
    temp = [int(i) for i in input().split()]
    k.append(temp[0])
    for j in temp[1:]:
        s[j - 1].append(i)
p = [int(i) for i in input().split()]
count = 0
for i in range(2**n):
    state = [0 for _ in range(m)]
    for j in range(n):
        # スイッチがついていたら、つながっている電球に+1する
        if (i >> j) & 1:
            for k in s[j]:
                state[k] = (state[k] + 1) % 2
    if state == p:
        count += 1
print(count)

-from numpy import * - -s = [[int(j) for j in input().split()][1:] for i in range(m)] +k = [] +# s[i] := i番目のスイッチについている電球群 +s = [[] for _ in range(n)] +for i in range(m): +    temp = [int(i) for i in input().split()] +    k.append(temp[0]) +    for j in temp[1:]: +        s[j - 1].append(i) -a = 0 +count = 0 -    b = array([(i >> j) & 1 for j in range(n)]) -    if [sum(b[array(k) - 1]) % 2 for k in s] == p: -        a += 1 -print(a) +    state = [0 for _ in range(m)] +    for j in range(n): +        # スイッチがついていたら、つながっている電球に+1する +        if (i >> j) & 1: +            for k in s[j]: +                state[k] = (state[k] + 1) % 2 +    if state == p: +        count += 1 +print(count)