We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.
Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.
How many combinations of "on" and "off" states of the switches light all the bulbs?

-----Constraints-----
 - 1 \leq N, M \leq 10
 - 1 \leq k_i \leq N
 - 1 \leq s_{ij} \leq N
 - s_{ia} \neq s_{ib} (a \neq b)
 - p_i is 0 or 1.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M
k_1 s_{11} s_{12} ... s_{1k_1}
:
k_M s_{M1} s_{M2} ... s_{Mk_M}
p_1 p_2 ... p_M

-----Output-----
Print the number of combinations of "on" and "off" states of the switches that light all the bulbs.

-----Sample Input-----
2 2
2 1 2
1 2
0 1

-----Sample Output-----
1

 - Bulb 1 is lighted when there is an even number of switches that are "on" among the following: Switch 1 and 2.
 - Bulb 2 is lighted when there is an odd number of switches that are "on" among the following: Switch 2.
There are four possible combinations of states of (Switch 1, Switch 2): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print 1.

Difficulty: introductory

Starter code:

Solutions:
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2 ** n):
    t = ['off'] * n
    x = i
    j = 0
    while x > 0:
        if x % 2 != 0:
            t[j] = 'on'
        x = x // 2
        j += 1
    flg = True
    for j in range(m):
        z = 0
        for k in range(1,s[j][0]+1):
            if t[s[j][k]-1] == 'on':
                z += 1
        if z % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1
print(ans)

n,m = map(int,input().split())
f = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
count = 0
for i in range(2**n):
  Bit = [0]*n
  for j in range(n):
    if (i>>j)&1:
      Bit[j]=1
  same = 0
  for k in range(m):
    sum = 0
    for l in range(f[k][0]):
      if Bit[f[k][l+1]-1] == 1:
        sum += 1
    if sum % 2 !=p[k]:
      break
  else:
    count += 1
print(count)

n,m=map(int,input().split())
ks=[[] for i in range(m)]
for i in range(m):
  ks[i]=list(map(lambda x:int(x)-1,input().split()))
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  l=[0]*n
  for j in range(n):
    l[j]=1 if i&1 else 0
    i>>=1
  
  # light check
  for j in range(m):
    s=sum([l[k] for k in ks[j][1:]])
    if s%2!=p[j]:
      break
  else:
    ans+=1

print(ans) 

N, M = map(int,input().split())
K = []
S = []
for i in range(M):
    k = 0
    s = []
    k, *s = map(int,input().split())
    K.append(k)
    S.append(s)
P = list(map(int,input().split()))
res = 0
for bit in range(1 << N):
    judge = True
    for i in range(M):
        cnt = 0
        for s in S[i]:
            cnt += (bit >> s-1) & 1
        if cnt % 2 != P[i]:
            judge = False
            break
    if judge:
        res += 1
print(res)

from itertools import product


N, M = list(map(int, input().split()))
bulbs = [list([int(x) - 1 for x in input().split()]) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for x in product([0, 1], repeat=N):
    is_on = [0] * M
    for i in range(M):
        k, *switches = bulbs[i]
        cnt = sum(x[s] for s in switches)
        if cnt % 2 == P[i]:
            is_on[i] = 1
    if all(is_on):
        ans += 1
print(ans)


N, M = map(int, input().split())
switch = []
for _ in range(M):
  tmp = list(map(int, input().split()))
  switch.append(tmp[1:])
p = list(map(int, input().split()))

from itertools import product
candidate = list(product([0,1], repeat=N))

ans = 0
for cand in candidate:
  flag = True
  for idx, snum in enumerate(switch):
    tmp = 0
    for s in snum:
      tmp += cand[s-1]
    if p[idx] != tmp%2:
      flag = False
      break
  if flag:
    ans += 1
print(ans)

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

n,m=map(int,input().split())
ks=[]
for i in range(m):
  t=list(map(int,input().split()))
  ks.append(t)
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  on=0
  for j in range(m):
    cnt=0
    for k in range(ks[j][0]):
      if 1<<(ks[j][k+1]-1) & i:
        cnt+=1
    if cnt%2==p[j]:
      on+=1
    if on==m:
      ans+=1
print(ans)

N,M = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    s = i
    b = [0]*N
    for j in range(N):
        if s >= (2**(N-j-1)):
            s -= 2**(N-j-1)
            b[j] = 1
    for j in range(M):
        on = 0
        for k in range(ks[j][0]):
            if b[ks[j][k+1]-1] == 1:
                on += 1
        if on%2 != p[j]:
            break
    else:
        ans += 1
print(ans)

n,m = map(int,input().split())
bulbbit = [0]*m # 電球とつながっているSWをbit表現
for i in range(m):
    tmp = list(map(int,input().split()))
    for j in range(1,tmp[0]+1):
        bulbbit[i] |= 1<<(tmp[j]-1)
p = list(map(int,input().split()))

ans = 0
for s in range(1<<n):
    cnt = 0
    for i in range(m):
        swon = 0
        for j in range(n):
            if s>>j&1 and bulbbit[i]>>j&1:
                swon += 1
        if swon%2 == p[i]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)

N,M = map(int,input().split())
mat = [[int(i) for i in input().split()] for k in range(M)]
p = [int(i) for i in input().split()]
switch = [0]*N
O = [0]*M
L = [False]*M
ans = 0

for i in range(2 ** (N)):
    switchsub = list(format(i,'b'))
    for j in range(len(switchsub)):
        switch[-j-1] = switchsub[-j-1]
    for j in range(N):
        if(switch[j] == "1"):
            for k in range(M):
                for l in range(1,len(mat[k])):
                    if(mat[k][l] == j+1):
                        O[k] += 1
    for j in range(M):
        if(O[j] % 2 == p[j]):
            L[j] = True
    if(False not in L):
        ans += 1
        switch = [0]*N
        O = [0]*M
        L = [False]*M
    if(False in L):
        switch = [0]*N
        O = [0]*M
        L = [False]*M

print(ans)

N, M = list(map(int, input().split()))

K = []
for i in range(M):
    K.append(list(map(int, input().split())))

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

ans = 0
for i in range(1 << N):
    flg = True
    for j in range(M):
        n = 0
        for k in K[j][1:]:
            n += i >> (k - 1) & 1
        if n % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)


n,m = map(int,input().split())
swithes = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
total = 0

for i in range(2**n):
    bag = []
    ans = 0
    for j in range(n):
        if i >> j & 1:
            bag.append(j+1)
    for k in range(m):
        a = 0
        for l in range(swithes[k][0]):
            if swithes[k][l+1] in bag:
                a += 1
        if a % 2 == p[k]:
            ans += 1
    
    if ans == m:
        total += 1

print(total)

num_of_switch, light = list(map(int, input().split()))
ligth_list = [list(map(int,input().split())) for _ in range(light)]
on_list = list(map(int, input().split()))

num_of_patern = 2 ** num_of_switch
patern = 0

for i in range(num_of_patern):
	on = []
	light_counter = 0
	for j in range(num_of_switch):  #スイッチのオンの場所
		if ((i >> j) & 1):
			on.append(j + 1)
	for j in range(light):   #どの電球が付いているかの判定
		count = 0
		num_connect = ligth_list[j][0]
		#print(on)
		if on_list[j] == 1:
			for n in range(len(on)):
				if on[n] in ligth_list[j][1:]:
					count += 1
			if count % 2 == 1:
				light_counter += 1
		else:
			for m in range(len(on)):
				if on[m] in ligth_list[j][1:]:
					count += 1
			if count % 2 == 0:
				light_counter += 1
	if light_counter == light:
		#print(i)
		patern += 1
	del on[:]
print(patern)




# cs: c nnected switches
n, m = list(map(int, input().split()))

# cs: connected switches
cs = [list(map(int, input().split())) for _ in range(m)]
ps = list(map(int, input().split()))

# bit全探索(0: すべてoffは不要)
ans = 0
# on: 0:消えてる、1:点いてる
# 10: 1 2  3   4 
# 0b: 1 10 11, 100..
for on in range(2**n):
    # bin: バイナリ文字列に変換
    # 3 -> '0b11'
    # rust で右0埋め
    patern = bin(on)[2:].rjust(n, '0')
    ok = True

    for i in range(m):
        ct = 0
        for j in range(cs[i][0]):
            if patern[cs[i][j+1] - 1] == '1':
                ct += 1
        if ct%2 != ps[i]:
            ok = False
    if ok:
        ans += 1
print(ans)


3
#coding: utf-8

N, M = (int(x) for x in input().split())

S = []
for i in range(M):
    items = [int(x)-1 for x in input().split()]
    S.append(items[1:])

P = [int(x) for x in input().split()]

ret = 0
for bit in range(2**N):
    on = [i for i in range(N) if bit & (1 << i)]
    ok = True
    for i in range(M):
        s = S[i]
        p = P[i]
        if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
    if ok:
        ret += 1
print(ret)


# -*- coding: utf-8 -*-

def func(sw, p, bit):
    sum_on = 0
    for k in range(sw[0]):
        idx = sw[k+1]-1
        if bit[idx] == 1:
            sum_on += 1
    if sum_on % 2 == p:
        res = 1
    else:
        res = 0
    return res


N,M = list(map(int, input().split()))
SW = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    bit = [0] * N
    for j in range(N):
        div = 1 << j
        bit[j] = (i // div) % 2

    cnt = 0
    for m in range(M):
        res = func(SW[m], P[m], bit)
        if res == 1:
            cnt += 1
    
    if cnt == M:
        ans += 1

print(ans)


def abc128c_switches():
    import itertools
    n, m = map(int, input().split())
    s = []
    for _ in range(m):
        v = list(map(int, input().split()))
        v = v[1:]
        s.append(v)
    p = list(map(int, input().split()))
    pattern = itertools.product([0,1], repeat=n)
    result = 0
    for pat in pattern:
        cnt = 0
        for i in range(m):
            total = 0
            for j in s[i]:
                if pat[j-1] == 1:
                    total += 1
            if total %2==p[i]:
                cnt +=1
        if cnt == m:
            result += 1
    print(result)

abc128c_switches()

import sys
sys.setrecursionlimit(10**9)
input=sys.stdin.readline

N,M=map(int,input().split())
lamps=[list(map(lambda x:int(x)-1,input().split()))[1:] for _ in range(M)]
p=list(map(int,input().split()))

ans=0

#bit全探索
for i in range(1<<N):
  for lamp in range(M):
    on_sum=0
    for j in range(N):
      if i>>j&1 and j in lamps[lamp]:
        on_sum+=1
    if on_sum%2 !=p[lamp]:
      break
  else:
    ans+=1
print(ans)

# author:  Taichicchi
# created: 16.09.2020 23:07:07

import sys

N, M = list(map(int, input().split()))

k = []
s = []

for i in range(M):
    _k, *_s = list(map(int, input().split()))
    k.append(_k)
    s.append(_s)

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


for i in range(2 ** N):
    sw = [0 for _ in range(N)]
    for j in range(N):
        if i >> j & 1:
            sw[j] = 1

    for m in range(M):
        mod = 0
        for switch in s[m]:
            mod += sw[switch - 1]
        if mod % 2 != p[m]:
            break
    else:
        ans += 1

print(ans)


import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
  N,M = i_map()
  K = []
  for i in range(M):
    l = i_list()
    l.pop(0)
    K.append(l)
  P = i_list()
  cnt = 0

  for i in range(2**N):
    trial = []
    for j in range(N):
      if i >> j & 1:
        trial.append(1)
      else:
        trial.append(0)
    flg = True
    for h,g in enumerate(K):
      num = 0
      for r in g:
        if trial[r-1] == 1:
          num += 1
      if num%2 != P[h]:
        flg = False
    if flg == True:
      cnt += 1

  print(cnt)





 
 


def __starting_point():
    main()
__starting_point()

from itertools import product

N, M = list(map(int, input().split()))
k = []
S = []
for _ in range(M):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    S.append(ks[1:])
p = list(map(int, input().split()))

onoff = list(product([0, 1], repeat = N))

ans = 0
for i in onoff:
    cnt = 0
    for ind, s in enumerate(S):
        state = 0
        for o in s:
            state += i[o-1]
        if state % 2 == p[ind]:
            cnt += 1
    if cnt == M:
        ans += 1

print(ans)


n,m = list(map(int, input().split()))
K = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    bit = [i>>j&1 for j in range(n)]
    for j,k in enumerate(K):
        if p[j] != sum([bit[l-1] for l in k])%2:
            break
    else:
        ans += 1
print(ans)


def abc128_c():
    # n個のスイッチ、m個の電球
    N, M = list(map(int, input().split()))

    connected_switches = []
    for i in range(M):
        # [k, s1, s2, ...sn][1:]
        tmp = list(map(int, input().split()))[1:]
        connected_switches.append(tmp)

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

    ans = 0

    # スイッチの状態(ON/OFF)をbitですべて列挙する
    for i in range(2 ** N):
        # 各電球が点灯しているかをチェックする
        for j in range(M):
            on_switch_count = 0
            # スイッチがつながっていて、かつ、onになっているものをカウント
            for k in range(N):
                # connected_switches[j]には[s1, s2, ...]が入っているため+1が必要
                if k + 1 in connected_switches[j] and ((i >> k) & 1):
                    on_switch_count += 1

            # 電灯をチェックして一つでもついていないものがあればそのスイッチの状態ではすべての電灯が付くという条件を満たせない
            if on_switch_count % 2 != p[j]:
                break
            
            if j == (M - 1):
                ans += 1

    print(ans)

def __starting_point():
    abc128_c()

__starting_point()

import re
import sys
import math
import itertools
import bisect
import heapq#.heapify:Priority Queueに変換 
#.heappop:最小値取得, .heappush:要素挿入
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def get_primenumber(number):#素数列挙
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list
def factrization_prime(number):#素因数分解
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
num = []
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,m = I()
switch = [l() for _ in range(m)]
p = l()

for bit in range(2**n):
    poi = [0]*n
    for i in range(n):
        if (bit>>i)&1:
            poi[i] = 1
    for j in range(m):
        ans = 0
        for k in range(switch[j][0]):
            if poi[switch[j][k+1]-1] == 1:
                ans += 1
        if ans % 2 != p[j]:
            break
    else:
        cnt += 1
print(cnt)

# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisect_left


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return list(map(int,input().split()))

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

def bindex(a,x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return i
    return None


class UnionFind:
    def __init__(self, n):
        self.r = [-1]*(n+1)

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x,y = y,x
        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -1 * self.r[self.root(x)]


class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



def __starting_point():
    N, M = mulinputs()
    ks, ss, ps = [], [], []
    for _ in range(M):
        k, *s = list(mulinputs())
        ks.append(k)
        ss.append(s)
    ps = list(mulinputs())

    cnt = 0
    for n in range((1<<N)):
        state = [0] * N
        for j in range(N):
            state[j] = (n&(1<<j))>>j
        is_light = True
        for j in range(M):
            icnt = 0
            for s in ss[j]:
                icnt += state[s-1]
            if icnt%2 != ps[j]:
                is_light = False
                break
        if is_light:
            cnt+=1

    # 出力
    print(cnt)


__starting_point()

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

for i in range(2**n):
    judge = True
    switch = [('off') for _ in range(n)]
    for j in range(len(switch)):
        if (i >> j) & 1:
            switch[j] = 'on'
    for k in range(m):
        count = 0
        for l in range(ks[k][0]):
            if switch[ks[k][l+1]-1] == 'on':
                count += 1
        if count % 2 != p[k]:
            judge = False
            break
    if judge == True:
        ans += 1

print(ans)

N, M = list(map(int, input().split()))
Switch = [list([int(a) - 1 for a in input().split()])[1:] for i in range(M)]
P = list(map(int, input().split()))
from itertools import product

Target = product([0, 1], repeat=N)
ans = 0
for T in Target:
    akari = []
    for i, S in enumerate(Switch):
        temp = 0
        for s in S:
            a = T[s]
            if a == 1:
                temp += 1
        akari.append(temp)
    isOK = True
    for j, ak in enumerate(akari):
        if ak % 2 != P[j]: isOK = False
    if isOK:
        ans += 1
print(ans)


from itertools import product
n,m = list(map(int, input().split()))
S = []
for _ in range(m):
    k, *s = list(map(int, input().split()))
    S.append(s)
p = list(map(int, input().split()))

ans = 0
for pattern in product(range(2), repeat=n):
    # 電球がつくかチェック
    for x,y in zip(S, p):
        on_cnt = sum([pattern[s-1] == 1 for s in x])
        if on_cnt % 2 != y:
            break
    else:
        ans += 1

print(ans)

import copy

def dfs(i,lst):
    nonlocal ans
    if i==n:
        ans.append(lst)
        return
    tmp1 = copy.copy(lst)
    tmp1.append(0)
    dfs(i+1,tmp1)
    tmp2 = copy.copy(lst)
    tmp2.append(1)
    dfs(i+1,tmp2)

n,m = map(int,input().split())
ans = []
tmp = [0]
dfs(0,tmp)
#print(ans)
s = []
k = []
for i in range(m):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])
p = list(map(int,input().split()))
#print(k)
#print(s)
#print(p)
cnt = 0
for i in range(len(ans)):
    cnt_i = 0
    for mi in range(m):
        sum_s = 0
        for ki in range(len(s[mi])):
            sum_s += ans[i][s[mi][ki]]
        if sum_s%2==p[mi]:
            cnt_i += 1
    if cnt_i==m:
        cnt += 1
print(cnt)

n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    onoffs = [int(j) for j in list(bin(i)[2:].zfill(n))]
    Flag = True
    for lamp in range(m):
        k = a[lamp][0]
        info = [l - 1 for l in  a[lamp][1:]]
        tmp = 0
        for index in info:
            if onoffs[index]:
                tmp += 1
        if tmp % 2 != p[lamp]:
            Flag = False
            break
    if Flag:
        ans += 1
print(ans)

import sys
input = sys.stdin.readline

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

ans = 0

for i in range(2 ** n):
  c = [False] * n
  for j in range(n):
    if (i >> j) & 1: c[j] = True
  for j in range(m):
    count, l = 0, ks[j][0]
    for k in range(l):
      if c[ks[j][k+1]-1]: count += 1
    if count % 2 != p[j]: break
  else: ans += 1

print(ans)

3
#coding: utf-8

N, M = (int(x) for x in input().split())

S = []
for i in range(M):
    S.append([int(x)-1 for x in input().split()][1:])
P = [int(x) for x in input().split()]

ret = 0
for bit in range(2**N):
    on = [i for i in range(N) if bit & (1 << i)]
    if all(sum(1 for switch in S[i] if switch in on) % 2 == P[i] for i in range(M)):
        ret += 1
print(ret)


import itertools

N,M = list(map(int, input().split()))
A = []

for m in range(M):
    a = list(map(int, input().split()))
    A.append(a[1:])

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

S = itertools.product([0,1],repeat=N)
ans = 0

for s in S:
    flag = True
    for i in range(M):
        temp = 0
        for a in A[i]:
            temp += s[a-1]
        if temp % 2 != P[i]:
            flag = False
    if flag == True:
        ans += 1

print(ans)


import copy

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

for i in range(m):
    st = list(map(int, input().split()))
    s.append([0]+st)


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

# 全bit探索
for i in range(2**(n)):
    lst = copy.deepcopy(s) # list のコピーにはcopy.copy()を用いる(2重配列以上はdeepcopy()を用いる)
    flag = True
    for j in range(n):
        if i >> j & 1 == 1:
            for k in lst:
                for l in range(2, k[1]+2):
                    if k[l]-1 == j:
                        k[0] += 1
    # 偶数奇数が合えば ans+=1
    for b in range(len(p)):
        if p[b] != lst[b][0]%2:
            flag = False
    if flag == True:
        ans +=1

print(ans)

n,m=map(int,input().split())
s=[[x for x in map(int,input().split())]for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(1<<n):
  c=1
  for j in range(m):
    t=0
    for k in range(1,s[j][0]+1):
      if (i>>(s[j][k]-1))&1==1:
        t+=1
    if t%2!=p[j]:
      c=0
      break
  if c:
    ans+=1
print(ans)

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

n,m = map(int,input().split())
line = []
for i in range(m):
  k,*s = map(int,input().split())
  line.append(list(s))
p = list(map(int,input().split()))

ans = 0
for bit in range(1<<n):
  switch = [0]*(n+1)
  tf = 1
  for i in range(n):
    if (bit>>i)&1:
      switch[i+1] = 1
  for i in range(m):
    cnt = 0
    for v in line[i]:
      if switch[v]:
        cnt += 1
    if cnt%2!=p[i]:
      tf = 0
  if tf:
    ans += 1
print(ans) 

n, m = map(int, input().split(' '))
K = []
S = []
for i in range(m):
    l = list(map(int, input().split(' ')))
    K.append(l[0])
    S.append(l[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2**n):
    light = 0
    for j in range(m):
        sw = 0
        for s in S[j]:
            if (i>>(s-1))&1:
                sw += 1
        if sw%2 == p[j]:
            light+=1
    if light == m:
        ans += 1
print(ans)

from itertools import combinations
n, m = map(int, input().split())
ksm = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

onoff = [0]*n
total = 0
def dfs(i, onoff):
    nonlocal total
    if i == n:
        flag = True
        for idx, j in enumerate(ksm):
            count = 0
            for k in j[1:]:
                count += onoff[k-1]
            if count%2 != p[idx]:
                flag = False
        if flag:
            total += 1
        return
    dfs(i+1, onoff[:])
    dfs(i+1, onoff[:i]+[1]+onoff[i+1:])

dfs(0, onoff)
print(total)

n,m = map(int, input().split(" "))
ks = [list(map(int, input().split(" "))) for i in range(m)]
p = list(map(int, input().split(" ")))
total = 0
for i in range(2 ** n):
  count = 0
  den = [0 for i in range(m+1)]
  for j in range(n):
    if i >> j & 1:
      for k in range(m):
        #print(i, j+1, ks[k][1:])
        if j+1 in ks[k][1:]:
          den[k+1] += 1
  #print(i, den)
  for j in range(m):
    if den[j+1] % 2 == p[j]:
      count += 1
  if count == m:
    total += 1
print(total)

N, M = map(int, input().split())
s = [list(map(lambda x:int(x)-1, input().split()[1:])) for _ in range(M)]
p = list(map(int, input().split()))
 
ans = 0
for i in range(2**N): # 全てのスイッチの (on, off) の組み合わせ
  # 電球jが点灯する条件：繋がっているk_j個のスイッチのうち、onの個数を2で割った余りがp_jに等しい
  bulb_num = 0 # 点灯する電球の個数
  for j in range(M): # ある (on, off) の組において、点灯する電球の個数を求める
    on_num = 0 # 電球jに繋がっているスイッチのうち、onの個数
    for k in range(N):
      # スイッチkがon かつ、電球jとスイッチkが繋がっているならば：
      if i >> k & 1 and k in s[j]: on_num += 1
    if (on_num - p[j]) % 2 == 0: bulb_num += 1
  if bulb_num == M: ans += 1
    
print(ans)

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


ans = 0
for i in range(2**n):
    s = 0
    for j in range(m):
        c = 0
        for k in range(len(ks[j])-1) :
            if ((i >> (ks[j][k+1]-1)) & 1) :
                c += 1
        if c % 2 == p[j]:
            s += 1
    if s == m :
        ans += 1

print(ans)


from itertools import product

n, m = map(int, input().split())
switches = []
for _ in range(m):
    x = list(map(int, input().split()))[1:]
    temp = []
    for i in range(n):
        if i + 1 in x:
            temp.append(1)
        else:
            temp.append(0)
    switches.append(temp)
p = list(map(int, input().split()))

ans = 0
for on_off in product([1, 0], repeat=n):
    flag = 1
    for i, switch in enumerate(switches):
        cnt = 0
        for x, y in zip(on_off, switch):
            if x == 1 and y == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = 0
    if flag:
        ans += 1

print(ans)

N = None
M = None
S = []
P = []

def __starting_point():
    N, M = map(int, input().split())
    for _ in range(M):
        row = list(map(int, input().split()))[1:]
        S.append(row)
    P = list(map(int, input().split()))
    ans = 0
    for bit in range(1<<N):
        on_switches = []
        light = 0
        for i in range(N):
            if bit>>i&1:
                on_switches.append(i)
        for i in range(M):
            cnt = 0
            for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
            if cnt%2==P[i]:
                light += 1
        if light==M:
            ans += 1
    print(ans)
__starting_point()

import sys
input = sys.stdin.readline

def slove():
    N, M = map(int,input().split())
    light = []
    for i in range(M):
        connecting_sw = list(map(int,input().split()))
        light.append(connecting_sw[1:])
    on = list(map(int,input().split()))
    #print(light)
    #print(on)

    ans = 0
    for i in range(1 << N):
        light_on = [0]*M
        for j in range(N):
            if i >> j & 1:
                a = 0
                for item in light:
                    if j+1 in item:
                        light_on[a] = (light_on[a]+1)%2
                    a += 1
        #print(light_on)
        a = 0
        for i in range(M):
            if on[i] == light_on[i]:
                a += 1
                continue
            break
        if a == M:
            ans += 1

    print(ans)
    
def __starting_point():
    slove()
__starting_point()

n, m = map(int,input().split())
k, s = [], []
for i in range(m):
  inp = list(map(int, input().split()))
  k_, s_ = inp[0], inp[1:]
  k.append(k_)
  s.append(s_)
p = list(map(int, input().split()))
ans = 0
for bit in range(1<<n):
  flg = True
  for i in range(m):
    cnt = 0
    for e in s[i]:
      e -= 1
      if bit & 1<<e: cnt += 1
    if cnt%2 != p[i]: flg = False
  if flg: ans += 1
print(ans)

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

from itertools import product
iterator=product(range(p),repeat=n)

s=[0 for i in range(m)]    
for i in range(m):
    S=list(map(int,input().split()))
    k=S[0]
    s[i]=S[1:]

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

ans=0
for idxs in iterator:
    tmp1=0
    for i in range(m):
        tmp2=0
        for j in s[i]:
            tmp2+=idxs[j-1]
        if tmp2%2==p[i]:
            tmp1+=1
    if tmp1==m:
        ans+=1
print(ans)

n, m = map(int, input().split())
s_lis = []

#ON/OFFのパターン
for i in range(2 ** n) :
    lis = []
    for j in range(len(bin(2 ** n)) - 3) :
        if (i >> j) & 1 :
            lis.append(1)
        else:
            lis.append(0)
    
    s_lis.append(lis)

#各電球の接続
b_lis = []
for k in range(m) :
    b_lis.append(list(map(int, input().split())))

#点灯条件
light = list(map(int, input().split()))

#各電球の合計
cnt = 0
for s in s_lis :
    c_lis = []
    for b in b_lis :
        c = 0
        for x in range(b[0]) :
            c += s[b[x + 1] - 1]
        c_lis.append(c)
    
    c_lis = list(map(lambda y : y % 2, c_lis))
    if c_lis == light :
        cnt += 1

print(cnt)

from itertools import product, repeat
import numpy as np

input_row = lambda : [int(_) for _ in input().split(' ')]

N, M = input_row()
C = np.zeros((M, N), dtype=np.int32)

for i in range(M):
    s = np.array(input_row()[1:]) # ignore k
    C[i, s-1] = 1 # s_ to zero index.

p = input_row()

all_on_num = 0
for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p

    if len(L[L == True]) == M:
        all_on_num += 1
print(all_on_num)




all_input=[] #appendのために宣言が必要
while True:
    try:
        all_input.append(list(map(int,input().split())))
    except:
        break;
        #または、return,os.returnをして止める。

N, M = all_input[0][0], all_input[0][1]
p = all_input[-1]
all_input.pop(0), all_input.pop(-1)
switch = [all_input[i][1:] for i in range(M)]
num_switch = [all_input[i][0] for i in range(M)]

all_on = 0
for i in range(2**N):
    num_light_on = 0 # M個の電球のうち，点灯するものの個数をincrementする
    for m in range(M):
        switch_on = 0
        for j in range(N):
            if (i >> j) & 1:
                if j+1 in switch[m]:
                    switch_on += 1
        if switch_on % 2 == p[m]:
            num_light_on += 1
    if num_light_on == M:
        all_on += 1
print(all_on)



from itertools import combinations

def getval():
    n,m = map(int,input().split())
    s = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
    p = list(map(int,input().split()))
    return n,m,s,p 

def main(n,m,s,p):
    l = [[] for i in range(n)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
    ans = 0
    for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
    print(ans)

def __starting_point():
    n,m,s,p = getval()
    main(n,m,s,p)
__starting_point()

n,m = list(map(int,input().split()))
light = [list(map(int,input().split())) for _ in range(m)]
lighton = list(map(int,input().split()))
swicth = []

for i in range(2**n):
    a = [0]*n
    for j in range(n):
        if (i>>j)&1:
            a[j] = 1
    swicth.append(a)

ans = 0

for x in swicth:
    for y in range(m):
        b = light[y][1:]
        total = 0
        for z in b:
            total += x[z-1]
        if total%2 != lighton[y]:
            break
    else:
        ans += 1

print(ans)



# cs: c nnected switches
n, m = list(map(int, input().split()))

def get_connected_switches():
    # k s1 s2 .. sn
    lst = list(map(int, input().split()))
    lst.pop(0) # k is not use
    return list([1<<(d-1) for d in lst])

# cs: connected switches
cs = [get_connected_switches() for _ in range(m)]
ps = list(map(int, input().split()))

# bit全探索(0: すべてoffは不要)
ans = 0
# on: 0:消えてる、1:点いてる
# 10: 1 2  3   4 
# 0b: 1 10 11, 100..
for on in range(2**n):
    ok = True
    for i in range(m):
        ct = 0
        for s in cs[i]:
            if s&on: ct += 1
        if ct%2 != ps[i]:
            ok = False
    if ok:
        ans += 1
print(ans)


N, M = list(map(int, input().split()))
k = []
s = []
for i in range(M):
    a = list(map(int, input().split()))
    k.append(a[0])
    s.append(a[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
    ri_count = 0
    for j in range(M):
        sw_count = 0
        for l in range(k[j]):
            if i>>(s[j][l]-1) & 1:
                sw_count += 1
        if sw_count%2 == p[j]:
            ri_count += 1
    if ri_count == M:
        ans += 1
print(ans)



n, m = list(map(int, input().split(' ')))
k = []
s = []
for i in range(m):
    a = list(map(int, input().split(' ')))
    k.append(a[0])
    s.append(a[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2**n):
    ri_cnt = 0
    for j in range(m):
        sw_cnt = 0
        for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
        if sw_cnt % 2 == p[j]:
            ri_cnt += 1
    if ri_cnt == m:
        ans += 1
print(ans)


N,M=map(int,input().split())
k=[]
s=[]
for i in range(M):
    ks=list(map(int,input().split()))
    k.append(ks[0])
    s.append(list(map(lambda x:x-1,ks[1:])))
p=list(map(int,input().split()))

ans=0
for i in range(2**N):
    isOK=True

    for j in range(M):
        sum=0
        for x in s[j]:
            sum+=(i>>x)&1
        
        if sum%2!=p[j]:
            isOK=False
    
    if isOK:
        ans+=1

print(ans)

def light(l,i):
    k=1<<(i-1)
    if l&k:
        return 1
    else:
        return 0

N, M = map(int,input().split())
s=list()
for j in range(0,M):
    s.append(0)
for j in range(0,M):
    s[j]=list(map(int,input().split()))
p=list(map(int,input().split()))

a=0
for l in range(0,1<<N):
    b=0
    for j in range(0,M):
        c=0
        for i in range(1,s[j][0]+1):
            c+=light(l,s[j][i])
        if c%2==p[j]:
            b+=1
    if b==M:
        a+=1
print(a)

n, m = map(int, input().split())
bulbs = []
ans = 0
for i in range(m):
    c = tuple(map(int, input().split()))
    bulbs.append(c[1:])
p = list(map(int, input().split()))
for i in range(2 ** n):
    cnt = 0
    for j, bulbs_sub in enumerate(bulbs):
        switch_on = 0
        for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
        if switch_on % 2 == p[j]:
                cnt += 1
    if cnt == m:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))

s_lst = [[False] * N for _ in range(M)]
for i in range(M):
    ks = list(map(int, input().split()))
    for j, value in enumerate(ks):
        if j != 0:
            s_lst[i][value-1] = True
p = list(map(int, input().split()))
# print(s_lst)

ans = 0
for bit in range(2**N):
    cnt = [0] * M
    for i in range(N):
        if (bit>>i) & 1 == 1:
            for j in range(M):
                if s_lst[j][i]:
                    cnt[j] += 1
    flug = True
    for i in range(M):
        if cnt[i] % 2 != p[i]:
            flug = False
    if flug:
        ans += 1
print(ans)


n,m = map(int, input().split())
ks = []
ss = []
for _ in range(m):
    row = list(map(lambda x: int(x)-1, input().split()))
    ks.append(row[0]+1)
    ss.append(row[1:])
ps = list(map(int, input().split()))

def is_bulb_on(bits, i):
    cnt = 0
    for s in ss[i]:
        if bits[s]:
            cnt += 1
    return cnt % 2 == ps[i]

def are_all_bulb_on(bits):
    good = True
    i = 0
    while good and i < m:
        good &= is_bulb_on(bits, i)
        i += 1
    return good

def rec(bits, i):
    if i == n:
        return 1 if are_all_bulb_on(bits) else 0
    cnt = 0
    cnt += rec(bits, i+1)
    bits[i] = 1
    cnt += rec(bits, i+1)
    bits[i] = 0
    return cnt

bits = [0]*n
print(rec(bits, 0))

from itertools import product


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

switch = []

for i in range(m):
  k, *s = map(int, input().split())
  s = list(s)
  switch.append(s)

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

for i in product(range(2), repeat=n):
  flag = True
  for s in range(m):
    cnt = 0
    for t in switch[s]:
      if i[t-1] == 1:
        cnt += 1
    if cnt % 2 != p[s]:
      flag = False
      break
  if flag == True:
    ans += 1

print(ans)

N,M=map(int, input().split())
ks=[list(map(int, input().split()))[1:] for _ in range(M)]
P=list(map(int, input().split()))
temp=[0]*M

ans=0

for i in range(2**N):
	temp=[0]*M
	for h in range(N):
		if i>>h & 1:
			for g in range(M):
				if h+1 in ks[g]:
					temp[g]+=1
	for k in range(M):
		temp[k]=temp[k]%2
	if temp==P:
		ans+=1
	
	#print(temp)

print(ans)

n,m = map(int, input().split(" "))
ks = [list(map(int, input().split(" "))) for i in range(m)]
p = list(map(int, input().split(" ")))
total = 0
for i in range(2 ** n):
  count = 0
  den = [0 for i in range(m+1)]
  for j in range(n):
    if i >> j & 1:
      for k in range(m):
        #print(i, j+1, ks[k][1:])
        if j+1 in ks[k][1:]:
          den[k+1] += 1
  #print(i, den)
  for j in range(m):
    if den[j+1] % 2 == p[j]:
      count += 1
  if count == m:
    total += 1
print(total)

N, M = list(map(int, input().split()))
S = [0]*M
answer = 0

for i in range(M):
    S[i] = list(map(int, input().split()))

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

for i in range(2**N):
    mb = '0' + str(N) + 'b'
    bi = format(i, mb)
    count = 0
    for j in range(M):
        on = 0
        for k in range(S[j][0]):
            on += int(bi[-S[j][k+1]])
        if on%2 == P[j]:
            count += 1
    if count == M:
        answer += 1

print(answer)

from itertools import product, repeat
import numpy as np

input_row = lambda : [int(_) for _ in input().split(' ')]

N, M = input_row()
C = np.zeros((M, N), dtype=np.int32)

for i in range(M):
    s = input_row()[1:]
    for s_ in s:
        C[i, s_-1] = 1

p = input_row()

all_on_num = 0

for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p
    L_on = L[L == True]
    all_on = len(L_on) == M

    if all_on:
        all_on_num += 1
print(all_on_num)



import math
N, M = list(map(int, input().split()))
switch = [0] * N
pattern = 2 ** N
ans = 0
for i in range(M):
  temp = input().split()[1:]
  for j in temp:
    switch[int(j) - 1] += (1 << i )
  
p = list(map(int, input().split()))
pbin = 0
temp = 1
for i in p:
  pbin += i * temp
  temp *= 2

for i in range(pattern):
  temp = 0
  j = 0
  while i > 0:
    if i & 1 == 1 :
      temp = temp ^ switch[j]
    j += 1
    i = i >> 1
  if pbin == temp:
    ans += 1
print(ans)


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

ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i >> (s-1) & 1:
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)


import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))

n,m=MI()
sws=[]
for i in range(m):
    sws.append(list(map(int,input().split())))
#print(sws)
ps=LI()
ans=0
for i in range(2**n):
    count=0
    for j in range(m):
        sm=0
        for k in range(1,len(sws[j])):
            sm+= (i>>(sws[j][k]-1)) %2
        #print(sm)
        if sm%2==ps[j]:
            count+=1
    if count==m:
        ans+=1
print(ans)


n,m = list(map(int,input().split()))
l = []
for i in range(1 << n):
    tmp = str(bin(i))[2:]
    l.append(tmp.zfill(n))
K = [list(map(int,input().split())) for _ in range(m)]
P = list(map(int,input().split()))
#print(P)
ans = 0
#print("----")
for i in range(len(l)):
    #スイッチの状態l[i]
    #付いている電球のリストO
    O = []
    for j in range(m):
        #電球のきになるすいっちの数K[j][0]
        ON = 0
        for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
        if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
    if sum(O) == m:
        #print(l[i])
        ans += 1
print(ans)



def f(i):
    if i == n:
        on = [0] * m
        for j in range(m):
            for k in range(1, s[j][0] + 1):
                if t[s[j][k] - 1]:
                    on[j] += 1
        for j in range(m):
            if not on[j] % 2 == p[j]:
                return
        nonlocal ans
        ans += 1
        return
    t[i] = 1
    f(i + 1)
    t[i] = 0
    f(i + 1)
    return

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
t = [0] * n
f(0)
print(ans)

n,m = map(int, input().split())
s = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
  for x,y in zip(s,p):
    flag = False
    for a in x:
      if i>>a&1: flag = not flag
    if int(flag) != y: break
  else: ans += 1
print(ans)

import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

#bit全部作ってる
#bit = [i>>j&1 for j in range(N)]

n,m=MI()
lights=[LI() for _ in range(m)]
p_list=LI()

bit_list=[]
count=0
for i in range(2**n):
    bit = [i>>j&1 for j in range(n)]
    flag=0
    for j in range(m):
        ki=lights[j][0]
        onswitch=0
        for k in range(1,ki+1):
            si=lights[j][k]
            onswitch+=bit[si-1]
        if onswitch%2!=p_list[j]:
            flag+=1
    if flag==0:
        count+=1
print(count)

N,M = map(int,input().split())
conditions = []
for i in range(M):
    conditions.append(list(map(int,input().split()))[1:])
compair = list(map(int, input().split()))

master_list = []
for i in range(2 ** N):
    target = list(map(int,'{:010b}'.format(i)))[-N:]
    master_list.append(target)
    
result_list = []
for i in master_list:
    prepair_line = []
    for j in conditions:
        total = 0
        for k in j:
            total += i[k-1]
        prepair_line.append(total % 2)
    result_list.append(prepair_line)

cnt = 0
for i in result_list:
    if compair == i:
        cnt += 1

print(cnt)

import itertools
N,M = map(int,input().split())
Switch = []
for i in range(M):
    Swi = list(map(int,input().split()))
    S = Swi[0]
    Switch.append(Swi[1:S+1])
Plist = list(map(int,input().split()))
Ans = 0
L = [0,1]
c_list = list(itertools.product(L, repeat=N))
for comb in c_list:
    for i in range(M):
        Jud = 0
        Swi = Switch[i]
        for j in Swi:
            Jud += comb[j-1]
        if Jud%2 != Plist[i]:
            break
        elif i == M-1:
            Ans += 1
print(Ans)

#!/usr/bin/env python3

#import
#import math
#import numpy as np
N, M = list(map(int, input().split()))

K = {i: [] for i in range(M)}
for i in range(M):
    t = list(map(int, input().split()))
    for j in range(1, len(t)):
        K[i].append(t[j] - 1)

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

ans = 0

for i in range(2 ** N):
    switch = [False] * N
    for j in range(N):
        if (i >> j) & 1:
            switch[j] = True

    isok = True
    for m in range(M):
        t = 0
        for k in K[m]:
            if switch[k]:
                t += 1

        if (t % 2) != P[m]:
            isok = False

    if isok:
        ans += 1

print(ans)




N, M = map(int, input().split())
A = [[0 for _ in range(N)] for _ in range(M)]
for i in range(M):
    S = list(map(int, input().split()))
    for j in S[1:]: 
        A[i][j-1] = 1

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

ans = 0
for bit in range(2**N):
    b = bin(bit)[2:].zfill(N)
    X = [0] * M
    for i in range(M):
        for j in range(N):
            if A[i][j] == 1 and b[j] == '1':
                X[i] = (X[i] + 1) % 2

    tmp = 0
    for i in range(M):
        if P[i] == X[i]:
            tmp += 1
    
    if tmp == M: 
        ans += 1

print(ans)

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

ans=0
for i in range(2**n):
    sw=[]
    on=0
    for j in range(n):
        sw.append(i>>j & 1)
    for k in range(m):
        if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
            on +=1
    if on==m:
        ans +=1
print(ans)


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

ans = 0
for i in range(2**n):
    bnt = 0
    for j in range(m):
        cnt = 0
        for l in range(1, len(ks[j])):
            if (i>>(ks[j][l]-1))&1 == 1:
                cnt += 1
        if cnt%2 == p[j]:
            bnt += 1
    if bnt == m:
        ans += 1
print(ans)

N, M = map(int, input().split())
s = [list(map(lambda x:int(x)-1, input().split()[1:])) for _ in range(M)]
p = list(map(int, input().split()))
 
ans = 0
for i in range(2**N): # 全てのスイッチの (on, off) の組み合わせ
  # 電球jが点灯する条件：繋がっているk_j個のスイッチのうち、onの個数を2で割った余りがp_jに等しい
  bulb_num = 0 # 点灯する電球の個数
  for j in range(M): # ある (on, off) の組において、点灯する電球の個数を求める
    on_num = 0 # 電球jに繋がっているスイッチのうち、onの個数
    for k in range(N):
      # スイッチkがon かつ、電球jとスイッチkが繋がっているならば：
      if i >> k & 1 and k in s[j]: on_num += 1
    if (on_num - p[j]) % 2 == 0: bulb_num += 1
  if bulb_num == M: ans += 1
    
print(ans)

#import math
import itertools
#import numpy as np
#from collections import deque


INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,m=INTM()
    cnct=[]
    for i in range(m):
        temp=LIST()
        temp=temp[1:]
        cnct.append(temp)
    ps=LIST()
    ans=0
    
    for bit in range(2**n):
        check=[0]*m
        for i in range(n):
            if (bit>>i)&1:
                for k in range(m):
                    if i+1 in cnct[k]:
                        check[k]+=1
        
        flg=True
        for k in range(m):
            if check[k]%2!=ps[k]:
                flg=False
        
        if flg:
            ans+=1
    
    print(ans)


def __starting_point():
    do()
__starting_point()

#!/usr/bin/env python3

def II(): return int(input())
def MII(): return list(map(int, input().split()))
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans)

def __starting_point():
    main()

__starting_point()

n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
 
ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i & (1 << s-1):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)

N,M=map(int,input().split())
lamps=[list(map(lambda x:int(x)-1,input().split()))[1:] for _ in range(M)]
p=list(map(int,input().split()))

ans=0

#bit全探索
for i in range(1<<N):
  for lamp in range(M):
    on_sum=0
    for j in range(N):
      if i>>j&1 and j in lamps[lamp]:
        on_sum+=1
    if on_sum%2 !=p[lamp]:
      break
  else:
    ans+=1
print(ans)

#m = int(input())
n, m = list(map(int, input().split()))
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
switch = []
kl = []
for i in range(m):
    temp = list(map(int, input().split()))
    kl.append(temp[0])
    switch.append(temp[1:])
pl = list(map(int, input().split()))
# print(switch)

pattern = [[0 for _ in range(n)] for _1 in range(2**n)]
for i in range(2**n):
    for j in range(n):
        if ((i >> j) & 1):  # 二進数iの下から数えてj桁目が1か否か
            pattern[i][j] = 1

ans = 0
for ptnum, spt in enumerate(pattern):
    islit = True
    for lightnum in range(m):
        count = 0
        for s in switch[lightnum]:
            if spt[s-1] == 1:
                count += 1
        if count % 2 != pl[lightnum]:
            islit = False
            break
    if islit:
        ans += 1
print(ans)


N, M = map(int,input().split())
K = []
S = []
for i in range(M):
    k = 0
    s = []
    k, *s = map(int,input().split())
    K.append(k)
    S.append(s)
P = list(map(int,input().split()))
res = 0
for bit in range(1 << N):
    judge = True
    for i in range(M):
        cnt = 0
        for s in S[i]:
            cnt += (bit >> s-1) & 1
        if cnt % 2 != P[i]:
            judge = False
    if judge:
        res += 1
print(res)

n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for _ in range(m)]
p=list(map(int,input().split()))
ans=0

for i in range(2**n):
    tmp=[]
    cnt=[0]*n
    for j in range(n):
        if (i>>j)&1:
            tmp.append(j+1)
    for k in range(m):
        if len(set(tmp)&set(s[k]))%2!=p[k]:
            break
    else:
        ans+=1
print(ans)

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

swl = [list(map(int, input().split())) for _ in range(m)]
pl = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    sw = [0]*n
    light_cnt = 0
    for j in range(n):
        if (i>>j)&1:
            sw[j] += 1
    for j in range(m):
        wl = swl[j][1:]
        sw_cnt = 0
        for wi in wl:
            if sw[wi-1] == 1:
                sw_cnt += 1
        if sw_cnt%2 == pl[j]:
            light_cnt += 1
    if light_cnt == m:
        ans += 1

print(ans)

n,m = map(int,input().split())
s = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    s.append(tmp[1:])
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    for j in range(m):
        count = 0
        check = True
        for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
        if count % 2 != p[j]:
            check = False
            break
    if check:
        ans += 1
print(ans)

3
import sys
input = lambda: sys.stdin.readline().strip()
n, m = [int(x) for x in input().split()]
s = [[int(x) - 1 for x in input().split()][1:] for i in range(m)]
p = [int(x) for x in input().split()]
print(sum(1 for mask in range(1 << n) if all(sum((mask >> bulb) & 1 for bulb in s[i]) % 2 == p[i] for i in range(m))))

n,m=map(int,input().split())
ks=[[] for i in range(m)]
for i in range(m):
  ks[i]=list(map(lambda x:int(x)-1,input().split()))
p=list(map(int,input().split()))

ans=0
for i in range(1<<n):
  l=[0]*n
  for j in range(n):
    l[j]=1 if i>>j&1 else 0
  
  # light check
  for j in range(m):
    s=sum([l[k] for k in ks[j][1:]])
    if s%2!=p[j]: break;
  else: ans+=1;

print(ans) 

N, M = list(map(int, input().split()))

swiches = []

for _ in range(M):
    swiches.append(list(map(int,input().split()))[1:])

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

temp = "0" + str(N) + "b"
case = []
for i in range(2 ** N):
    case.append(format(i, temp))

for a in range(len(swiches)):
    for b in range(len(swiches[a])):
        swiches[a][b] -= 1

ans = 0
for x in case:
    flag = 0
    for i in range(M):
        temp = 0
        for j in swiches[i]:
            temp += int(x[j])
        if temp % 2 == p[i]:
            flag += 1
    if flag == M:
        ans += 1

print(ans)



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

ans = 0
for i in range(2**n):
    light = 0
    for ki, j in enumerate(k):
        switch = 0
        for s in j[1:]:
            if i & (1 << s-1):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)



n,m = map(int, input().split())
li = []

for i in range(m):
    a = list(map(int, input().split()))
    li.append(a[1:])

p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    ok = 1
    s = []
    for j in range(n):
        if (i>>j)&1:
            s.append(j)
    for j in range(m):
        tmp = 0
        for k in li[j]:
            if  k-1 in s:
                tmp += 1
        if tmp%2!=p[j]:
            ok=0
    if ok:
        ans += 1
print(ans)

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

ans = 0
for i in range(2**n):
    flag = True
    for j in range(m):
        on = 0
        a = False
        for l in ks[j]:
            if a and (i>>(l-1)) & 1:
                on += 1
            a = True
        if on % 2 != p[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

n,m=list(map(int,input().split()))
s=[[0]*10 for _ in range(m)]
for i in range(m):
    k=list(map(int,input().split()))
    for j in range(1,k[0]+1):
        s[i][10-k[j]]=1
import numpy as np
s=np.asarray(s)
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    binst=format(i,'010b')
    l=list(map(int,list(binst)))
    l=np.asarray(l)
    on=s&l
    onsum=np.sum(on,axis=1)%2
    err=0
    for j in range(m):
        if onsum[j]!=p[j]:
            err=1
            break
    if err==0:
        ans+=1
print(ans)


N,M=list(map(int,input().split()))
li=[]
ans=0
for i in range(M):
    s=list(map(int,input().split()))
    li.append(s)
p=list(map(int,input().split()))

for j in range(2**N):
    j=bin(j)
    j=str(j)
    j=j[2:]
    while len(j)!=N:
        j="0"+j
    flash=0
    for k in range(M):
        temp=0
        for l in range(li[k][0]):
            if j[li[k][l+1]-1]=="1":
                temp+=1
        if temp%2==p[k]:
            flash+=1
    if flash==M:
        ans+=1
print(ans)
        
            


n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
count = 0
for i in range(2 ** n):
    on_number = [0] * m
    for j in range(n):
        if i >> j & 1:
            for k in range(m):
                if (j + 1) in s[k][1:]:
                    on_number[k] += 1
    flag = 0
    for k in range(m):
        if on_number[k] % 2 == p[k]:
            flag += 1
        if flag == m:
            count += 1
print(count)