CodeEff/ECCO huggingface dataset:
# Original solution
# ABC128C - Switches
from itertools import product

n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(m)]
con = list(map(int, input().rstrip().split()))
ans = 0
for i in product(list(range(2)), repeat=n):
    cnt = 0
    for j in range(m):
        ons = 0
        for k in lst[j][1:]:
            if i[k - 1] == 1:
                ons += 1
        if ons % 2 == con[j]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)

# Optimized solution
# ABC128C - Switches
import sys
from itertools import product

input = sys.stdin.readline


n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(m)]
con = list(map(int, input().rstrip().split()))
ans = 0
for i in product(list(range(2)), repeat=n):
    cnt = 0
    for j in range(m):
        ons = 0
        for k in lst[j][1:]:
            if i[k - 1] == 1:
                ons += 1
        if ons % 2 == con[j]:
            cnt += 1
    if cnt == m:
        ans += 1
print(ans)
# Original solution
n,m=list(map(int,input().split()))
light=[]
ans=0
for i in range(m):
    List=list(map(int,input().split()))
    light.append(List)
p=list(map(int,input().split()))

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

# Optimized solution
n,m=list(map(int,input().split()))
light=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    state=[0]*n
    for j in range(n):
        if (i>>j&1):
            state[j]=1
    light_num=0
    for k in range(m):
        switch_num=0
        for l in range(1,light[k][0]+1):
            if state[light[k][l]-1]==1:
                switch_num+=1
        if switch_num%2==p[k]:
            light_num+=1
    if light_num==m:
        ans+=1
print(ans)
# Original solution
def main():
  import itertools
  n,m=list(map(int,input().split()))
  li=[list(map(int,input().split()))[1:] for _ in range(m)]
  p=tuple(map(int,input().split()))
  
  q=set(sum(li,[]))
  
  r=set(range(1,n+1))
  v=r-q
  
  ans=0
  
  for i in range(0,len(q)+1):
    for s in itertools.combinations(q,i):
      s=set(s)
      for j,t in enumerate(li):
        u=s&set(t)
        if len(u)%2==p[j]:
          continue
        else:
          break
      else:
        ans+=2**(len(v))
   
  print(ans)
  
  
if __name__=="__main__":
  main()

# Optimized solution
def main():
  import itertools
  n,m=list(map(int,input().split()))
  li=[list(map(int,input().split()))[1:] for _ in range(m)]
  p=tuple(map(int,input().split()))
  
  q=set(sum(li,[]))
  r=set(range(1,n+1))
  v=r-q
  
  ans=0
  
  for i in range(0,len(q)+1):
    for s in itertools.combinations(q,i):
      s=set(s)
      t=all(len(s&set(u))%2==w for u,w in zip(li,p))
      if t==True:
        ans+=2**(len(v))
   
  print(ans)
  
  
if __name__=="__main__":
  main()
# Original solution
f = lambda : list(map(int, input().split()))
n, m = f()
ll = [[0]*n for i in range(m)]
for i in range(m):
  k, *t = f()
  for j in range(k):
    ll[i][t[j]-1] = 1
lp = list(f())

import itertools as it
lt = [p for p in it.product([0,1], repeat=n)]

ans = 0
for p in lt:
  lj = []
  for l in ll:
    lj.append(sum(a*b for a, b in zip(p,l))%2)
  if lp == lj:
    ans += 1

print(ans)

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

n, m = f()
ll = [[0]*n for i in range(m)]
for i in range(m):
  k, *t = f()
  for j in range(k):
    ll[i][t[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)
# Original solution
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)

# Optimized solution
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))))
# Original solution
N, M = list(map(int, input().split()))
int_switch_repr = 2**N
light_bulbs_switches = []
for i in range(M):
  k_s = [int(x) for x in input().split()]
  k_i = k_s[0]
  light_bulbs_switches.append(k_s[1:]) # i-th light bulb
P = [int(x) for x in input().split()]  # p_i

ans = 0
for itg in range(int_switch_repr):
  binary_switch_repr = "{w:{fill}{width}b}".format(w=itg, fill='0', width=N)
  all_on = True
  for lbs_i, p_i in zip(light_bulbs_switches, P):
    is_light_on = sum([1 for sw in lbs_i if binary_switch_repr[int(sw)-1]=='1'])%2 == p_i
    if not is_light_on:
      all_on = False
  if all_on:
    ans+=1

print(ans)

# Optimized solution
N, M = list(map(int, input().split()))
int_switch_repr = 2**N
light_bulbs_switches = []
for i in range(M):
  k_s = [int(x) for x in input().split()]
  k_i = k_s[0]
  light_bulbs_switches.append(k_s[1:]) # i-th light bulb
P = [int(x) for x in input().split()]  # p_i

ans = 0
for itg in range(int_switch_repr):
  binary_switch_repr = "{w:{fill}{width}b}".format(w=itg, fill='0', width=N)
  all_on = True
  for lbs_i, p_i in zip(light_bulbs_switches, P):
    is_light_on = sum([1 for sw in lbs_i if binary_switch_repr[int(sw)-1]=='1'])%2 == p_i
    if not is_light_on:
      all_on = False
      break
  if all_on:
    ans+=1

print(ans)
# Original solution
n,m = list(map(int,input().split()))
S = [list(map(int,input().split()))[1:] for i in range(m)]
P = list(map(int,input().split()))
ans = 0
#bit全探索
for bit in range(1<<n):
    on = []
    ok = True #全部の電球が光る
    for i in range(n):
        if (bit & (1<<i)):
            on.append(i+1)
    for i in range(m):
        p = P[i]
        c = 0
        for s in S[i]:
            if s in on: c+=1
        if c%2!=p: ok=False
    if ok:ans+=1
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))
d = []
for i in range(m):
    d.append(list(map(int,input().split())))
p = list(map(int,input().split()))

ans = 0
def search(x):
    global ans
    cnt = 0
    for i in range(m):
        c = 0
        for j in d[i][1:]:
            if x[j-1]==1:
                c += 1
        if c%2==p[i]:
            cnt += 1
    if cnt==m:ans+=1

from itertools import product
o = product(list(range(2)),repeat=n)
for i in o:
    search(i)
print(ans)
# Original solution
n,m = list(map(int,input().split()))
s = [0] * m
ans = 0
for i in range(m):
    s[i] = list(map(int,input().split()))
    s[i] = s[i][1:]
p = list(map(int,input().split()))
for k in range(2**n):
    a = format(k,'0'+str(n)+'b')
    t = True
    for i in range(m):
        if sum(a[j-1] == '1' for j in s[i])%2 != p[i]:
            t = False
            break
    ans += t
print(ans)


# Optimized solution
n,m = list(map(int,input().split()))
s = [0] * m
k = [0] * m
for i in range(m):
    s[i] = list(map(int,input().split()))
    k[i] = s[0]
    s[i] = s[i][1:]
p = list(map(int,input().split()))

ans = 0
b = '0' + str(n) + 'b'
for i in range(1 << n):
    sw = format(i,b)
    if all(sum(sw[g-1] == '1' for g in s[j])%2 == p[j] for j in range(m)):
        ans += 1
print(ans)
# Original solution
n, m = list(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 bit in range(2 ** n):
    q = 1
    for i in range(m):
        sum = 0
        for j in range(k[i]):
            if (bit >> (s[i][j] - 1)) & 1:
                sum += 1
        if sum % 2 != p[i]:
            q = 0
    if q == 1:
        ans += 1

print(ans)


# Optimized solution
N, M = list(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):  # all comb
    for j in range(M):  # k loop
        c = 0
        for k in range(N):  # s loop
            if ((i >> k) & 1) and (k + 1) in s[j][1:]:
                c += 1
        if c % 2 != p[j]:
            break
        elif j == M - 1:
            ans += 1
print(ans)
# Original solution
n,m=list(map(int,input().split()))
s=[]
k=[]
for i in range(m):
    ss=list(map(int,input().split()))
    k.append(ss[0])
    s.append(ss[1:])
p=list(map(int,input().split()))


def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count

ans=0

for bit in range(2**n):
    ok=True
    for mm in range(m):
        on=0
        for i in s[mm]:
            if bit & 2**(i-1)!=0:
                on+=1
        if on%2==p[mm]:
            pass
        else:
            ok=False

    if ok:ans+=1
print(ans)

# Optimized solution
n,m=list(map(int,input().split()))
k=[]
s=[]

def cntbin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count

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

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

ans=0
for i in range(2**n):
    ok=True
    for mm in range(m):
        if not ok:break
        mask=0
        for ss in s[mm]:
            mask+=1 << ss-1
        on=cntbin(i&mask)
        if p[mm]!=on%2:
            ok=False

    if ok:ans+=1

print(ans)
# Original solution
# https://atcoder.jp/contests/abc128/tasks/abc128_c
# なんかかすかに解いた記憶あるな？

# load data
N, M = list(map(int, input().split()))
S = []
for _ in range(M):
    S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))


def is_on(i, S, p):
    # bit表現 i のときSのスイッチの個数とpでonか返す
    cnt = 0
    for j in S:
        if (i >> (j - 1)) % 2:  # j番目のスイッチオン
            cnt += 1
    return cnt % 2 == p


ans = 0
# bit 全探索
for i in range(1 << N):  # N桁のbit全探索
    # 以下iの全パターンについて
    flg = True
    for s, p in zip(S, P):
        flg *= is_on(i, s, p)
    ans += flg
print(ans)


# Optimized solution
# https://atcoder.jp/contests/abc128/tasks/abc128_c
# なんかかすかに解いた記憶あるな？

# load data
N, M = list(map(int, input().split()))
S = []
for _ in range(M):
    S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))


def is_on(i, S, p):
    # bit表現 i のときSのスイッチの個数とpでonか返す
    cnt = 0
    for j in S:
        if (i >> (j - 1)) % 2:  # j番目のスイッチオン
            cnt += 1
    return cnt % 2 == p


ans = 0
# bit 全探索
for i in range(1 << N):  # N桁のbit全探索
    # 以下iの全パターンについて
    flg = True
    for s, p in zip(S, P):
        if not is_on(i, s, p):
            flg = False
            break
    ans += flg
print(ans)
# Original solution
N, M = list(map(int, input().split()))
K = []; S = []
for _ 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):
    flag = 0
    stat = str(bin(i)[2:])
    stat = stat.rjust(N, "0")
    for j in range(M):
        p = 0
        for l in S[j]:
            p += int(stat[l-1])
        if p % 2 != P[j]:
            flag = 1
    if flag == 0:
        ans += 1

print(ans)


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

ans = 0
for i in range(2**N):
    flag = True
    for a in range(M):
        cnt = 0
        for b in lightList[a][1:]:
            if not (i & (1<<b-1)):
                cnt += 1
        if cnt % 2 != P[a]:
            flag = False
    if flag:
        ans += 1
print(ans)
# Original solution
#N = int(input())
n, m = list(map(int, input().split()))
#hl = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(m)]
pl = list(map(int, input().split()))
count=0
for i in range(2**n):
    b = bin(i)
    switch = [False for i in range(n)]
    boollist=[]
    for j in range(n):
        if ((i >> j) & 1):
            switch[j] = True
    for j in range(m):
        k = l[j][0]
        sl = l[j][1:]
        total=0
        for sij in sl:
            if switch[sij-1]:
                total+=1
        if total % 2 == pl[j]:
            boollist.append(True)
        else:
            boollist.append(False)
    if all(boollist):
        count += 1
print(count)



# Optimized solution
#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)
# Original solution
n, m = [int(i) for i in input().split()]
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
cnt = 0
for i in range(2**n):
  on = set(j + 1 for j in range(n) if i >> j & 1 == 1)
  flag = True
  for j in range(m):
    _, *s = ks[j]
    flag &= len(on & set(s)) % 2 == p[j]
  cnt += flag
print(cnt)


# Optimized solution
from itertools import product

n, m = list(map(int, input().split()))
l = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
c = 0
for sw in product((0, 1), repeat=n):
    for i in range(m):
        if sum(sw[si - 1] for si in l[i][1:]) % 2 != p[i]:
            break
    else:
        c += 1
print(c)
# Original solution
# 2019-11-13 21:06:16(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, m = [int(x) for x in sys.stdin.readline().split()]
    
    on_off_patterns = [''.join(pattern) for pattern in itertools.product('01', repeat=n)]
    
    bulbs = [[int(x) for x in sys.stdin.readline()[1:].split()] for _ in range(m)]
    p = [int(x) for x in sys.stdin.readline().split()]

    combinations = 0
    for i in range(2**n):
        pattern = on_off_patterns[i]
        for j in range(m):
            switches = bulbs[j]
            on_count = 0
            for switch in switches:
                if pattern[switch-1] == '1':
                    on_count += 1
            if on_count % 2 == p[j]:
                continue
            else:
                break
        else:
            combinations += 1
    
    print(combinations)
    
    # enumerate on/off-patters by using binary number.


if __name__ == "__main__":
    main()


# Optimized solution
import sys

n, m = list(map(int, sys.stdin.readline().split()))
s = [set(map(int, sys.stdin.readline().split()[1:])) for _ in range(m)]
*p, = list(map(int, sys.stdin.readline().split()))

def main():
    combs = 0
    for i in range(2 ** n):
        t = set([j + 1 for j in range(n) if i >> j & 1])
        for k in range(m):
            if len(s[k] & t) & 1 != p[k]:
                break
        else:
            combs += 1
    
    return combs

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
N, M = list(map(int,input().split()))
state = []
for _ in range(M):
  lst = list(map(int, input().split()))
  state.append(lst[1:])#switch numbers each denkyu
p = list(map(int, input().split()))#numbers switches on %2 == pi 
ans = 0
for i in range(2**N):
  total = 0
  for j in range(M):
    cnt = 0
    for s in state[j]:
      s -= 1
      if (i >> s) & 1:#全スイッチのパターン一つ一つについて、各電球の各スイッチがオンになっているか
        cnt += 1
    cnt %= 2
    if cnt == p[j]:
      total += 1
  if total == M:
    ans += 1
print(ans)

# Optimized solution
N, M = list(map(int,input().split()))
state = []
for _ in range(M):
  lst = list(map(int, input().split()))
  state.append(lst[1:])#switch numbers each denkyu
p = list(map(int, input().split()))#numbers switches on %2 == pi 
ans = 0
for i in range(2**N):
  total = 0
  for j in range(M):
    cnt = 0
    for s in state[j]:
      s -= 1
      if (i >> s) & 1:#全スイッチのパターン一つ一つについて、各電球の各スイッチがオンになっているか
        cnt += 1
    cnt %= 2
    if cnt == p[j]:
      total += 1
    else:
      break
  if total == M:
    ans += 1
print(ans)
# Original solution
#入力
N, M = list(map(int, input().split()))

#入力: 電球iについての情報
lst = []
for i in range(M):
    a = list(map(int, input().split()))
    lst += [a]
#入力: どのような情報であればOKかのリスト
p = list(map(int, input().split()))

# print ('lst', lst)

#計算部分
ans = 0 #全探索用の答え
for i in range(2 ** N): #1をon, 0をoffとする2bit
    #最大でもスイッチは10桁＋2進数であることを表す部分2桁
    a = format(i, '012b')
    #2進数をリストとして保存, 前2桁は2進数であることを表す部分のため不要 
    lst2 = list(a[2:]) #右からスイッチ1, 2, ... Nと逆順になっていることに注意
    # print ('lst2', lst2)
    #あるスイッチの付け方が題意を満たしているか判断するフラグ
    flag = True 
    l = 0 #電球番号-1(リストのため)
    for j in lst: #i番目のスイッチの繋がっていることの情報
        # print ('j[1:]', j[1:])
        count = 0 #ONのスイッチの個数を数える
        for k in j[1:]: #s_i番目のスイッチの状態を読み出す、最初の一桁はスイッチの数
            # print ('k', k)
            if lst2[9-k+1] == '1': #ONの時、カウントを増やす
                count += 1
                # print ('B')
        # print ('count', count)
        # print ('p[l]', p[l])
        if count%2 != p[l]: #ONになっているスイッチの数//2が題意を満たしているかを判断
            flag = False #題意を満たしていなかったらフラグをFalseにする
            # print ('C')
        l += 1 #電球番号を一つ増やす
    if flag: #全ての電球を確認して、フラグがまだTrueなら答えを+1
        ans += 1
        # print ('A')

print (ans)

# Optimized solution
N, M = list(map(int, input().split()))
lst = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

count = 0
#bit全探索
for i in range(2**N): #スイッチの状態をbit-全探索
    c = [0] * M
    for j in range(N): #j桁目を確認
        if (i >> j) & 1: #j桁目 = j個目のスイッチがONの時
            for k in range(M): #M個の電球に対して確認
                if j+1 in lst[k][1:]:
                    c[k] += 1
    flag = True
    for l in range(M):
        if c[l]%2 != p[l]:
            flag = False
    if flag:
        count += 1


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

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

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

result = 0
for m in range(2**N):
    switches = list(map(int, list(str(bin(m))[2:])))
    switches = [0]*(N-len(switches)) + switches

    flag = True
    for idx, bulb in enumerate(bulbs):
        count = 0
        for switch in bulb:
            count += switches[switch-1]
        if count % 2 != P[idx]:
            flag = False
            break
    if flag:
        result += 1
print(result)


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

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

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

result = 0
for m in range(2**N):

    flag = True
    for idx, bulb in enumerate(bulbs):
        count = 0
        for switch in bulb:
            count += (m >> (switch-1)) & 1
        if count % 2 != P[idx]:
            flag = False
            break
    if flag:
        result += 1
print(result)
# Original solution
from collections import deque


n, m = list(map(int, input().split()))
s = [0] * m
k = [0] * m
for i in range(m):
    s[i] = deque(list(map(int, input().split())))
    k[i] = deque.popleft(s[i])
    s[i] = list(s[i])
p = list(map(int, input().split()))
cnt = 0
for i in range(2 ** n):
    l = [0] * n
    for j in range(n):
        if (i >> j) & 1:
            l[j] = 1
    for k in range(m):
        total = 0
        ans = True
        for num in s[k]:
            idx = num - 1
            if l[idx] == 1:
                total += 1
        if total % 2 != p[k]:
            ans = False
            break
    if ans:
        cnt += 1
print(cnt)

# Optimized solution
n, m = list(map(int, input().split()))
s = [0] * m
for i in range(m):
    s[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
ans = 0
for bit in range(2 << (n-1)):
    l = [0] * n
    for i in range(n):
        if bit >> i & 1:
            l[i] += 1
    for i in range(m):
        cnt = 0
        flag = True
        for j in s[i]:
            if l[j-1] == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)
# Original solution
n,m = list(map(int,input().split()))
res = 0
Q = []
for i in range(m):
    Q.append(list(map(int,input().split()))[1:])
P = list(map(int,input().split()))

for s in range(1<<n):
    tmp = 0
    for i in range(len(Q)):
        cnt = 0
        for t in Q[i]:
            if s>>(t-1) &1 == 1:
                cnt += 1
        if cnt % 2 == P[i]:
            tmp += 1
    if tmp == m:
        res += 1
print(res)

# Optimized solution
N,M = list(map(int,input().split()))
S = []
for _ in range(M):
    S.append(list(map(int,input().split()))[1:])
P = list(map(int,input().split()))
res = 0
for i in range(2**N):
    tmp = 0
    for j in range(M):
        ON = 0
        for s in S[j]:
            if (i >> s-1)&1 == 1:
                ON += 1
        if ON % 2 == P[j]:
            tmp += 1
    if tmp == M:
        res += 1
print(res)
# Original solution
n, m = list(map(int, input().split(' ')))
k = [0] * m
s = [[]] * m
for i in range(m):
  _input = [num for num in map(int, input().split(' '))]
  k[i] = _input[0]
  s[i] = _input[1:]
p = [num for num in map(int, input().split(' '))]

# print(n, m)
# print(k)
# print(s)
# print(p)

# スイッチのパターンデータ作成
s_pattern = [''] * (2**n)
str_format = '{:0' + str(n) + 'b}'
for i in range(2**n):
  s_pattern[i] = str_format.format(i)
# print(s_pattern)

ans = 0

for i in range(2**n):
  pattern = s_pattern[i]
  for j in range(m):
    need_switches = s[j]
    on_count = 0
    for switch in need_switches:
      if pattern[switch-1] == '1':
        on_count += 1
    # print(on_count, p[j])
    # 電球が点灯するか
    if on_count % 2 == p[j]:
      continue
    else:
      break
  else:
    # break で抜けていなければ場合はすべての電球が点灯する
    ans += 1

print(ans)

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

sl = [[]] * m

for i in range(m):
  s = [num for num in map(int, input().split())]
  sl[i] = s

  
p = [num for num in map(int, input().split())]
# print(p, sl)

ans = 0
# すべてのスイッチの状態を bit全探索 (各bit 1: on, 0: off)
for i in range(1 << n):
  # print('i: ', i)
  # そのスイッチの状態で各電球が光るか
  for j in range(m):
    s = sl[j]
    ons = 0
    # 光ってる数を数える
    for k in range(1, s[0]+1):
      # bit桁 = スイッチ番号 - 1 なので、現在のスイッチの状態はこの電球の対象か
      if i & (1 << (s[k]-1)):
        ons += 1
    # 1つでも光っていないと break
    if ons % 2 != p[j]:
      break
  else:
    # すべての処理でbreakしない == すべての電球が光っている
    ans += 1


print(ans)
# Original solution
ks=[]
n,m=list(map(int,input().split()))
for i in range(m):
	ks.append(list(map(int,input().split())))
p=list(map(int,input().split()))
ans_ans=0
for i in range(2**n):
	num="0"*10+bin(i)
	ans=0
	for j in range(m):
		cnt=0
		for k in range(n):
			if num[-k-1]=="1" and k+1 in ks[j][1:]:
				cnt+=1
		if cnt%2==p[j]:
			ans+=1
	if ans==m:
		ans_ans+=1
print(ans_ans)


		


# Optimized solution
n,m=list(map(int,input().split()))
ks=[]
for _ in range(m):
	rr=list(map(int,input().split()))
	ks.append(rr)
p=list(map(int,input().split()))
def two(x):
	return "0"*(n-len(bin(x)[2:]))+bin(x)[2:]
ans=0
for i in range(2**n):
	r=two(i)
	f=1
	for j in range(m):
		cnt=0
		for k in range(ks[j][0]):
			if r[ks[j][k+1]-1]=="1":
				cnt+=1
		if cnt%2!=p[j]:
			f=0
			break
	ans+=f
print(ans)