CodeEff/ECCO huggingface dataset:
# Original solution
N, M = list(map(int, input().split()))
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ans = 0
B = 1 << N
for i in range(B):
  L = [0] * M
  for j in range(M):
    for k in ks[j][1:]:
      if i >> (k - 1) & 1:
        L[j] = (L[j] + 1) % 2
  for j in range(M):
    if L[j] != p[j]:
      break
  else:
    ans += 1

print(ans)

# Optimized solution
N, M = list(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(1 << N):
  for j in range(M):
    t = 0
    for k in range(1, ks[j][0] + 1):
      if i >> (ks[j][k] - 1) & 1:
        t += 1
    if t % 2 != p[j]:
      break
  else:
    ans += 1

print(ans)
# Original solution
N,M = list(map(int,input().split()))
ls = []

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

p = list(map(int,input().split()))
#greedy O(2^N)(MN) : (all set of switch N) = 2^10 * M 10 10^4 OK
ans = 0
for i in range(2**N): # all set of N  2**N == 1 << N (shif operator N right shift)
  for j in range(M): # i_th lump consider
    cnt = 0 
    for k in ls[j]:
      if i&(1<<(k-1)): # if switch k is ON, then return non-zero(True)
        cnt += 1
    if cnt%2 != p[j]:
      break
  else:
    ans +=1
print(ans)


# Optimized solution
n,m = list(map(int,input().split()))
light = []
for i in range(m):
  light.append(list(map(int,input().split())))
p = list(map(int,input().split()))
# bit全探索 nで スイッチのパターンを全てためす
# 
ans = 0
for i in range(2**n):
  ng = 0
  for j in range(m):
    ans_j = 0
    for k in range(n):
      if i >> k & 1 and k+1 in light[j][1:]:#電球on かつk[i]の電球がついているなら+=1
        #print(light[j][1:],k)
        ans_j += 1
    #print(ans_j,i,p[j],ng)
    if ans_j % 2 != p[j]:
      ng = 1
  if ng == 0:
    ans += 1
print(ans)
# Original solution
N,M = list(map(int,input().split(" ")))
switch = []
for i in range(M):
    tmp = list(map(int,input().split(" ")))
    switch.append(tmp)

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


light = [0 for i in range(N)] 



def search(N,M,switch,p,l,light):
    if l<N:
        l += 1
        a=search(N,M,switch,p,l,light)
        light[l-1]+=1 
        b = search(N,M,switch,p,l,light)
        return a+b
    else:
        flag = 0
        for i in range(M):
            a = 0
            for j in range(switch[i][0]):
                a +=light[switch[i][j+1]-1]
            if a%2 == p[i]:
                continue
            else:
                flag = 1
                break
        if flag == 0:
            return 1
        else:
            return 0
  

ans = search(N,M,switch,p,0,light)
print(ans)

# Optimized solution
N,M = list(map(int,input().split(" ")))
light = []
for i in range(M):
    tmp = list(map(int,input().split(" ")))
    light.append(tmp)

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


switch = [0 for i in range(N)] 


def search(N,M,light,p,l,switch):
    if l<N:
        l += 1
        a=search(N,M,light,p,l,switch)
        switch[l-1]+=1 
        b = search(N,M,light,p,l,switch)
        return a+b
    else:
        flag = 0
        for i in range(M):
            a = 0
            for j in range(light[i][0]):
                a +=switch[light[i][j+1]-1]
            if a%2 == p[i]:
                continue
            else:
                flag = 1
                break
        if flag == 0:
            return 1
        else:
            return 0
  

ans = search(N,M,light,p,0,switch)
print(ans)
# Original solution
#
# abc128 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2
2 1 2
1 2
0 1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3
2 1 2
1 1
1 2
0 0 1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 2
3 1 2 5
2 2 3
1 0"""
        output = """8"""
        self.assertIO(input, output)


def resolve():
    N, M = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        m = 0
        for i in range(M):
            t = 0
            for j in range(1, S[i][0]+1):
                if bit & (1 << (S[i][j]-1)) != 0:
                    t += 1
            if t % 2 != P[i]:
                break
            else:
                m += 1
        if m == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


# Optimized solution
#
# abc128 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2
2 1 2
1 2
0 1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3
2 1 2
1 1
1 2
0 0 1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 2
3 1 2 5
2 2 3
1 0"""
        output = """8"""
        self.assertIO(input, output)


def resolve():
    N, M = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        m = 0
        for i in range(M):
            t = 0
            for j in range(1, S[i][0]+1):
                if bit & (1 << (S[i][j]-1)):
                    t += 1
            if t % 2 != P[i]:
                break
            else:
                m += 1
        if m == M:
            ans += 1
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()
# Original solution
# pythonで青くなるブログ
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = list(map(int, input().split()))
lamps = [list([int(x)-1 for x in input().split()])[1:]
         #1個目は繋がっているスイッチの個数
         #2個目以降が繋がっているスイッチの番号
         for _ in range(M)]
p = list(map(int, input().split()))
# on になっているスイッチの個数を2で割った余りがpiに等しい時に点灯
ans = 0

# bit全探索(スイッチの入れ方を全探索する)
for i in range(1 << N):
    for r in range(M):  # 全てのランプがついてるかチェック
        on_sum = 0  # ランプrにおいて、onのスイッチの数
        for j in range(N):  # スイッチのj番目について
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1  
                # スイッチjがランプrに繋がってて、onならon_sum+=1
        if on_sum % 2 != p[r]:  # on_off check
            break  # 一つでもoffなら次のbitに
    else:
        ans += 1
print(ans)

# Optimized solution
# pythonで青くなるブログ
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = list(map(int, input().split()))
lamps = [list([int(x)-1 for x in input().split()])[1:]
         #1個目は繋がっているスイッチの個数
         #2個目以降が繋がっているスイッチの番号、0始まりに
         for _ in range(M)]
p = list(map(int, input().split()))
# on になっているスイッチの個数を2で割った余りがpiに等しい時に点灯
ans = 0

# bit全探索(スイッチの入れ方を全探索する)
for i in range(1 << N):#2^N分、Bit検索
    for r in range(M):  # 全てのランプがついてるかチェック
        on_sum = 0  # ランプrにおいて、onのスイッチの数。電球はM個。
        for j in range(N):  # スイッチのj番目について
            if i >> j & 1 and j in lamps[r]:
            #j番目のフラグが立って、電球rのj番目のスイッチが入っていれば
                on_sum += 1  
                # スイッチjがランプrに繋がってて、onならon_sum+=1
        if on_sum % 2 != p[r]:  # on_off check
            break  # 一つでもoffなら次のbitに
    else:
        ans += 1
print(ans)
# Original solution
"""
n,m<=10
"""

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

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

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

ans = 0

for i in range(2**n):
    flag = True
    for k in range(m):
        tst = 0
        for sm in s[k]:
            tst ^= i>>(sm-1)&1
        if tst^p[k]:###
            flag = False
            break
    if flag:
        ans += 1

print(ans)

# Optimized solution
n,m = list(map(int, input().split( )))
sw = [0 for _ in range(m)]#でんきゅがつながってるスイッチ
for i in range(m):
    s = list(map(int, input().split( )))
    s = [si-1 for si in s[1:]]
    bt = 0
    for sj in s:#電球
        bt += 1<<sj
    sw[i] = bt
    
p = list(map(int, input().split( )))

#スイッチ
bit = 1<<n
ans = 0
for i in range(bit):#スイッチつけ方
    flag = True
    for j in range(m):#電球
        cnt = 0
        for k in range(n):#スイッチチェック
            cnt += (i&sw[j])>>k
        if cnt%2!=p[j]:
            flag = False
    if flag:
        ans += 1
print(ans)
# Original solution
import itertools

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


answer_count = 0
for switches in itertools.product((0, 1), repeat=N):
    on_count = 0
    for j in range(M):
        count = 0
        for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
        if count % 2 == p[j]:
            on_count += 1
    
    if on_count == M:
        answer_count += 1

print(answer_count)

# Optimized solution
N, M = list(map(int, input().split())) # Nはスイッチの数、Mは電球の数
lights = [[0] * N for _ in range(M)]
for i in range(M): 
    temp = list(map(int, input().split())) # 0番目はスイッチの個数、1番目以降はスイッチを示す
    k = temp[0]
    switches = temp[1:]
    for j in range(k):
        lights[i][switches[j]-1] = 1
P = list(map(int, input().split())) # 個数を2で割ったあまりが要素と等しい場合に点灯する

answer_count = 0
for i in range(2**N):
    flag = True
    for k in range(M):
        count = 0
        for j in range(N):
            if (i >> j) & 1:
                count += lights[k][j]
        if count % 2 != P[k]:
            flag = False
            break
    if flag:
        answer_count += 1

print(answer_count)
# Original solution
N, M = list(map(int, input().split()))

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

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

    for k in range(M):
        count = 0
        for l in range(1, len(S[k])):
            if temp[S[k][l] - 1] == 1:
                count += 1
        if count % 2 != p[k]:
            break
    else:
        ans += 1
    temp = [0]*N

print(ans)


# Optimized solution
import itertools

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

# スイッチが付いているか付いていないかを表す集合
ans = 0
for bit in itertools.product([0, 1], repeat=N):
    for d, p in zip(data, P):
        cnt = 0
        for i in d[1:]:
            if bit[i - 1] == 1:
                cnt += 1
        if cnt % 2 != p:
            break
    else:
        ans += 1

print(ans)
# Original solution
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
ks = nan(m)
p = na()

ans = 0
for i in range(2 ** n):
    on = dict()
    for j in range(n):
        if (i >> j) & 1:
            on[j + 1] = True
    l = 0
    for j in range(m):
        k, s = ks[j][0], ks[j][1:]
        sum_on = 0
        for a in range(k):
            if on.get(s[a], False):
                sum_on += 1
        if sum_on % 2 == p[j]:
            l += 1
    if l == m:
        ans += 1

print(ans)

# Optimized solution
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
ks = nan(m)
p = na()

ans = 0
for i in range(2 ** n):
    ok = True
    for j in range(m):
        k, s = ks[j][0], ks[j][1:]
        sum_on = 0
        for a in range(k):
            if (i >> (s[a] - 1)) & 1:
                sum_on += 1
        if sum_on % 2 != p[j]:
            ok = False
    if ok:
        ans += 1

print(ans)
# Original solution
n,m=list(map(int,input().split()))
l=[list(map(int,input().split()))[1:] for i in range(m)]
p=list(map(int,input().split()))
form = "0" + str(n) + "b"
ans=0
for i in range(2**n):
	ptr = format(i,form)
	flg = True
	for j in range(m):
		s= sum(int(ptr[k-1]) for k in l[j])
		if s%2 != p[j]:
			flg = False
	if flg == True:
		ans+=1
print(ans)

# Optimized solution
n,m=list(map(int,input().split()))
k=[0]*m
s=[set() for i in range(m)]
for i in range(m):
  k[i],*t=list(map(int,input().split()))
  for j in range(k[i]):
    s[i].add(t[j]-1)
ans=0
p=list(map(int,input().split()))
for i in range(2**n):
  switch=[0]*n
  flag=True
  for j in range(n):
    if i>>j&1:
      switch[j]=1
  for j in range(m):
    on_cnt=0
    for k in range(n):
      if switch[k]==1 and k in s[j]:
        on_cnt+=1
    if on_cnt%2!=p[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)
# Original solution
N, M = list(map(int, input().split()))
s = []
for _ in range(M):
    kss = list(map(int, input().split()))
    s.append(set([x - 1 for x in kss[1:]]))
p = list(map(int, input().split()))

ans = 0
for bit in range(1 << N):
    on_counts = [0] * M
    for i in range(N):
        if bit & (1 << i):
            for m in range(M):
                if i in s[m]:
                    on_counts[m] += 1
    if [x % 2 for x in on_counts] == p:
        ans += 1
print(ans)

# Optimized solution
N, M = list(map(int, input().split()))
B = [None] * M
for i in range(M):
    ks = list(map(int, input().split()))
    B[i] = [s - 1 for s in ks[1:]]
p = list(map(int, input().split()))

ans = 0
bit = 0
for bit in range(1 << N):
    for i, b in enumerate(B):
        if p[i] != (len([1 for s in b if bit & (1 << s)]) % 2):
            break
    else:
        ans += 1
print(ans)
# Original solution
N,M = list(map(int,input().split()))
k = [0] * M
s = [0] * M
for i in range(M):
    ks = list(map(int,input().split()))
    for j,x in enumerate(ks):
        if j == 0:
            k[i] = x
            continue
        s[i] += 1 << x-1
p = [int(i) for i in input().split()]

answer = 0
for i in range(2**N):
    count = [0] * M
    for j in range(M):
        tmp = s[j] & i
        while tmp:
            if tmp & 1:
                count[j] += 1
            tmp >>= 1

        # j番目の電球が光る場合 count[j] = 1
        if count[j] % 2 == p[j]:
            count[j] = 1
        else:
            count[j] = 0

    # 全ての電球が点灯する場合
    if not 0 in count:
        answer += 1

print(answer)

# Optimized solution
N,M = list(map(int,input().split()))
S = []
for _ in range(M):
    INPUT = tuple(map(int,input().split()))
    S.append(INPUT[1:])
P = [int(i) for i in input().split()]

ans = 0
for i in range(2**N):
    # state[i]: スイッチiがon
    state = [False] * N
    for j in range(N):
        if 1 & (i >> j):
            state[j] = True
    
    # 全ての電球が点灯するか判定
    flag = True
    for j in range(M):
        cnt = 0
        for s in S[j]:
            if state[s-1]:
                cnt += 1
        if cnt % 2 != P[j]:
            flag = False
    
    if flag:
        ans += 1

print(ans)
# Original solution
from itertools import product

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

k = []
s = []
for _ in range(M):
    t = list(map(int, input().split()))
    k.append(t[0])
    s.append(t[1:])

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

ans = sum(
    all(
        sum(
            t[j - 1]
            for j in s[i]
        ) % 2 == p[i]
        for i in range(M)
    )
    for t in product(list(range(2)), repeat=N)
)

print(ans)


# Optimized solution
from itertools import product

# 入力
N, M = list(map(int, input().split()))
k, s = list(zip(
    *(
        (int(k), list(map(int, s.split())))
        for _ in range(M)
        for k, s in [input().split(maxsplit=1)]
    )
))
p = list(map(int, input().split()))

# 全探索で解を求める
ans = sum(
    all(
        sum(t[j - 1] for j in S) % 2 == P
        for S, P in zip(s, p)
    )
    for t in product(list(range(2)), repeat=N)
)

# 出力
print(ans)
# Original solution
def fbit(k,n):
    t=[]
    kk=k
    for i in range(n):
        t.append(kk%2)
        kk=int(kk/2)
    return t        

n,m=list(map(int,input().split()))
s=[]
for i in range(m):
    si=[]
    for j in range(n):
        si.append(0)
    s.append(si)
    
for j in range(m):
    str=input().split()
    k_m=int(str[0])
    for k in range(k_m):
        ii=int(str[k+1])-1
        s[j][ii]=1

str=input().split()
p=[]
for k in range(m):
    p.append(int(str[k]))

icnt=0
for k in range(2**n):
    icnt2=0
    bit=fbit(k,n)
    for im in range(m):
        icnt3=0
        for kn in range(n):
            icnt3=icnt3+bit[kn]*s[im][kn]
        if icnt3%2==p[im]:
            icnt2=icnt2+1
    if icnt2==m:
        icnt=icnt+1
print(icnt)       

# Optimized solution

import itertools

n,m=list(map(int,input().split()))
ks=[]
for i in range(m):
    ksi=list(map(int,input().split()))
    ks.append(ksi)
p=list(map(int,input().split()))
    
icnt=0
for i in itertools.product([0,1], repeat=n):
    yn=""
    mcnt=0
    for j in range(m):
        ksum=0
        for k in range(ks[j][0]):
            if i[ks[j][k+1]-1]==1:
                ksum+=1
        if ksum%2==p[j]:
            mcnt+=1
    if mcnt==m:
        icnt+=1
#    print(icnt,mcnt,i)
print(icnt)
# Original solution
# coding: utf-8
N, M = list(map(int, input().split()))
K, S = [], []
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()))

ans = 0
for bit in range(2**N):
    lamp = 0
    switch = [0] * N
    # インデックスに対応したランプがついてる(1, 0)ように変換
    for j in range(N):
        if (bit >> j) & 1 == 1:
            switch[j] = 1
    # 各電球ごとに確認
    for i in range(M):
        cnt = 0
        for k in range(N):
            if k+1 in S[i] and switch[k] == 1:
                cnt += 1
        # print("cnt", cnt)
        if cnt % 2 == P[i]:
            lamp += 1
    if lamp == M:
        ans += 1
print(ans)

# Optimized solution
# coding: utf-8
N, M = list(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
# print(S)
for bit in range(2**N):
    l = []
    for j in range(N):
        if bit >> j & 1 == 1:
            l.append(1)
        else:
            l.append(0)
    flag = True
    for j in range(M):
        t = S[j]
        cnt = 0
        for k in range(len(S[j])):
            if l[t[k]-1] == 1:
                cnt += 1
            # else:
            #     flag = False
        if cnt % 2 != P[j]:
            flag = False
    if flag:
        # print(bin(bit))
        ans += 1
print(ans)
# Original solution
#!/usr/bin/env python

def main():
    N, M = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))
    ans = 0

    # all possible switch patterns
    for i in range(2 ** N):
        light_on = 0
        # all switch conditions
        for j in range(M):
            switch_on = 0
            # all connected switch
            for k in S[j][1:]:
                # convert integer to binary
                if (i >> k-1) & 1:
                    switch_on += 1
            if switch_on %2 == P[j]:
                light_on += 1
        if light_on == M:
            ans += 1

    return ans

if __name__ == '__main__':
    print((main()))



# Optimized solution
#!/usr/bin/env python
def main():
    N, M = list(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(1<<N):
        isConflict = False

        for j in range(M):
            tmp = 0
            for k in ks[j][1:]:
                k -= 1
                tmp += (i>>k)
            if tmp%2 != p[j]:
                break
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,p = LI()
    print(((a*3+p)//2))
    return

#B
def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l+[i]
    s.sort(key = lambda x:(x[0],-int(x[1])))
    for i,a,b in s:
        print((b+1))
    return

#C
def C():
    def dfs(d,k):
        if d == n:
            l.append(k)
        else:
            dfs(d+1,k+[0])
            dfs(d+1,k+[1])
    n,m = LI()
    l = []
    dfs(0,[])
    qu = LIR(m)
    p = LI()
    ans = 0
    for k in l:
        s = 0
        for q in range(m):
            num = qu[q][0]
            lis = list([x-1 for x in qu[q][1:]])
            su = 0
            for i in lis:
                su ^= k[i]
            if su == p[q]:
                s += 1
        if s == m:
            ans += 1
    print(ans)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    s = LIR(m)
    p = LI()
    ans = 0
    for i in range(m):
        s[i] = sum([1<<(j-1) for j in s[i][1:]])
    for b in range(1<<n):
        for i in range(m):
            if bin(s[i]&b).count("1")&1 != p[i]:
                break
        else:ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()