qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

ans = 0
N,M = map(int,readline().split())
L = []

for i in range(M):
    k,*S = map(int,readline().split())
    L.append(S)

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

A = list(itertools.product([0,1],repeat=N))

for i in A:
    sw = [False] * N
    for j in range(M):
        count = 0
        for k in L[j]:
            count += i[k-1]

        if count % 2 == P[j]:
            sw[j] = True
            
    if sum(sw) == N:
        ans += 1
print(ans)

# Fixed code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

ans = 0
N,M = map(int,readline().split())
L = []

for i in range(M):
    k,*S = map(int,readline().split())
    L.append(S)

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

A = list(itertools.product([0,1],repeat=N))

for i in A:
    sw = [False] * M
    for j in range(M):
        count = 0
        for k in L[j]:
            count += i[k-1]

        if count % 2 == P[j]:
            sw[j] = True
            
    if sum(sw) == M:
        ans += 1
print(ans)
# Buggy code:
import copy

N,M = map(int, input().split())
jisho = [[] for i in range(N)]
for i in range(M):
    val = input().split()
    for j in val[1:]:
        jisho[int(j)-1].append(i)

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

sw = []
def create_ki(data):
    if len(data) == N:
        sw.append(data)
        return
    tmp = copy.copy(data)
    tmp.append(0)
    create_ki(tmp)
    tmp2 = copy.copy(data)
    tmp2.append(1)
    create_ki(tmp2)

create_ki([])

ans = 0
for val in sw:
    num = 0
    sw2 = [0]*M
    for i in val:
        if i == 0:
            num += 1
            continue
        data = jisho[num]
        for j in data:
            sw2[j] += 1
        num += 1
    cn = 0
    for j in sw2:
        if j % 2 == p[cn]:
            break
        cn += 1
    if cn == M:
        ans += 1

print(ans)
mac:128 ry

# Fixed code:
import copy

N,M = map(int, input().split())
jisho = [[] for i in range(N)]
for i in range(M):
    val = input().split()
    for j in val[1:]:
        jisho[int(j)-1].append(i)

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

sw = []
def create_ki(data):
    if len(data) == N:
        sw.append(data)
        return
    tmp = copy.copy(data)
    tmp.append(0)
    create_ki(tmp)
    tmp2 = copy.copy(data)
    tmp2.append(1)
    create_ki(tmp2)

create_ki([])

ans = 0
for val in sw:
    num = 0
    sw2 = [0]*M
    for i in val:
        if i == 0:
            num += 1
            continue
        data = jisho[num]
        for j in data:
            sw2[j] += 1
        num += 1
    cn = 0
    for j in sw2:
        if j % 2 != p[cn]:
            break
        cn += 1
    if cn == M:
        ans += 1

print(ans)
# Buggy code:
# -*- coding: utf-8 -*-

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

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

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)


# Fixed code:
# -*- coding: utf-8 -*-

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

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)
# Buggy code:
def main():
    N,M = map(int, input().split())
    s = [[int(x) for x in input().split()] for _ in range(M)]
    p = [int(x) for x in input().split()]
    count=0
    for i in range(2**N):
        switch=[0]*N
        sw = bin(i)[2:]
        sw=sw[:-1]
        sw = "0"*(N-len(sw))+sw
        #for j in range(N):
            #switch[j] = int(sw[j])
        All=0   
        for j in range(M):
            Sum=0
            for k in s[j]:
                #if switch[k-1]==1:
                if int(sw[k-1])==1:
                    Sum+=1
            if Sum%2 == p[j]:
                All+=1
        if All==M:
            count+=1
    print(count)

main()

# Fixed code:
def main():
    N,M = map(int, input().split())
    s = [[int(x) for x in input().split()][1:] for _ in range(M)]
    p = [int(x) for x in input().split()]
    count=0
    for i in range(2**N):
        switch=[0]*N
        sw = bin(i)[2:]
        sw = "0"*(N-len(sw))+sw
        #print(sw)
        #for j in range(N):
            #switch[j] = int(sw[j])
        All=0   
        for j in range(M):
            Sum=0
            for k in s[j]:
                #if switch[k-1]==1:
                if int(sw[k-1])==1:
                    Sum+=1
            if Sum%2 == p[j]:
                All+=1
        if All==M:
            count+=1
    print(count)

main()
# Buggy code:
N,M = map(int,input().split())
KS = [[int(x) for x in input().split()] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    switch_pattern = bin(i)[2:].zfill(N)
    succes = 1
    for j in range(M):
      for k in KS[j]:
        switch_on = 0
        if switch_pattern[k-1] == '1':
          switch_on += 1
      if switch_on % 2 != P[j]:
            succes = 0
            break
    if succes == 1:
        ans += 1
print(ans)

# Fixed code:
N,M = map(int,input().split())
KS = [list(map(int,input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  switch_pattern = bin(i)[2:].zfill(N)
  succes = 1
  for j in range(M):
    switch_on = 0
    for k in KS[j]:
      if switch_pattern[k-1] == '1':
        switch_on += 1
    if switch_on % 2 != P[j]:
      succes = 0
      break
  if succes == 1:
      ans += 1
print(ans)
# Buggy code:
n,m = 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):
    binstr = list(reversed(format(i, '010b')))
    lightnum = 0
    for j in range(m):
        cnt = 0
        for s in light[j]:
            if binstr[s-1] == '1':
                cnt += 1
        if p[j] == cnt%2:
            lightnum += 1
    if lightnum == m:
        ans += 1
print(ans)


# Fixed code:
n,m = 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):
    binstr = list(reversed(format(i, '010b')))
    lightnum = 0
    for j in range(m):
        cnt = 0
        K = light[j][0]
        for k in range(1,K+1):
            s = light[j][k]
            if binstr[s-1] == '1':
                cnt += 1
        if p[j] == cnt%2:
            lightnum += 1
    if lightnum == m:
        ans += 1
print(ans)
# Buggy code:
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):
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)


# Fixed code:
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 >> (s-1) & 1:
                switch += 1
        if switch % 2 == p[ki]:
            light += 1
    if light == m:
        ans += 1
print(ans)
# Buggy code:
import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb and pattern).count('1') % 2 == pattern[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for bulb in input:
        for x in sys.stdin.readline().split()[1:]:
            bulb += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for i in range(2 ** num_switch):
        if all_lighted(input, mod, i): count += 1

    print(count)


if __name__ == "__main__":
    main()


# Fixed code:
import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb & pattern).count('1') % 2 == mod[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for i in range(num_bulb):
        for x in sys.stdin.readline().split()[1:]:
            input[i] += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for pattern in range(2 ** num_switch):
        if all_lighted(input, mod, pattern): count += 1

    print(count)


if __name__ == "__main__":
    main()
# Buggy code:
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):
    switch = [0]*N
    
    for j in range(N):
        if (i>>j & 1):
            switch[j] = 1
    
    n_on_light = 0
    
    for x in range(M):
        n_on_switch_for_one_light = 0
        for k in range(ks[x][0]):
            n_on_switch_for_one_light += switch[ks[x][k+1]-1]
        if n_on_switch_for_one_light%2 == p[x]:
            n_on_light += 1
    
    if n_on_light == M:
        print(switch)
        ans += 1
    
print(ans)

# Fixed code:
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):
    switch = [0]*N
    
    for j in range(N):
        if (i>>j & 1):
            switch[j] = 1
    
    n_on_light = 0
    
    for x in range(M):
        n_on_switch_for_one_light = 0
        for k in range(ks[x][0]):
            n_on_switch_for_one_light += switch[ks[x][k+1]-1]
        if n_on_switch_for_one_light%2 == p[x]:
            n_on_light += 1
    
    if n_on_light == M:
        ans += 1
    
print(ans)
# Buggy code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

s = getSomeInputListInt(m)
p = getInputListInt()

s_bit = []

for tmp_s in s:
    tmp_bit = 0
    for i in range(1, tmp_s[0] + 1, 1):
        aaa = 1 << (i - 1)
        tmp_bit = aaa | tmp_bit
    s_bit.append(tmp_bit)

ans = 0
for i in range(int(pow(2, m))):
    flg = True
    for j in range(m):
        cnt = bin(s_bit[j] & i).count("1")
        if cnt % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

# Fixed code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

s = getSomeInputListInt(m)
p = getInputListInt()

s_bit = []

for tmp_s in s:
    tmp_bit = 0
    for i in range(1, tmp_s[0] + 1, 1):
        aaa = 1 << (tmp_s[i] - 1)
        tmp_bit = aaa | tmp_bit
    s_bit.append(tmp_bit)

ans = 0
for i in range(int(pow(2, n))):
    flg = True
    for j in range(m):
        cnt = bin(s_bit[j] & i).count("1")
        if cnt % 2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)
# Buggy code:
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar.append(0)) + dfs(n-1, ar.append(1))
arr = []
ans = dfs(N, arr)
print(ans)

# Fixed code:
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar+[0]) + dfs(n-1, ar+[1])
arr = []
ans = dfs(N, arr)
print(ans)
# Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:00 2019

@author: Yamazaki Kenichi
"""

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):
    t = '{:010b}'.format(i)
    flg = True
    for j in range(M):
        tmp = 0
        for k in range(ks[j][0]):
            tmp += int(t[-ks[j][k]])
#        print(i,j,t,tmp,ans)
        if tmp%2 == p[j]:
            continue
        else:
            flg = False
            break
    if flg:
        ans += 1

            
print(ans)


# Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:00 2019

@author: Yamazaki Kenichi
"""

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):
    t = '{:010b}'.format(i)
    flg = True
    for j in range(M):
        tmp = 0
        for k in range(ks[j][0]):
            tmp += int(t[-ks[j][k+1]])
#        print(i,j,t,tmp,ans)
        if tmp%2 == p[j]:
            continue
        else:
            flg = False
            break
#    print(i,j,t,tmp,ans,flg)
    if flg:
        ans += 1

            
print(ans)
# Buggy code:
f=lambda:[*map(int,input().split())]
n,m=f()
S=[f()[1:] for _ in [0]*m]
p=f()
print(sum(all(sum(i>>-~k for k in S[j])%2==p[j] for j in range(m)) for i in range(2**n)))

# Fixed code:
f=lambda:map(int,input().split())
n,m=f()
S=[[0]*n for _ in [0]*m]
for i in range(m):
  _,*s=f()
  for j in s: S[i][j-1]=1
p=[*f()]
print(sum(all(sum(i>>j&1*S[k][j] for j in range(n))%2==p[k] for k in range(m)) for i in range(2**n)))
# Buggy code:
import itertools

switch, light = map(int, input().split())
ksm = []
for i in range(1, light+1):
    ks = input().split()
    ksm.append(ks)

pm = input().split()

ans = 0
for i in itertools.product([0, 1], repeat=switch):
    isOk = True
    for li in range(light):
        p = pm[li]
        ks = ksm[li]
        light_sum = 0
        for ksi in range(int(ks[0])):
            light_sum += i[int(ks[ksi + 1]) - 1]
        if light_sum % 2 != p:
            isOk = False
    if isOk:
        ans += 1
print(ans)


# Fixed code:
import itertools

switch, light = map(int, input().split())
ksm = []
for i in range(1, light+1):
    ks = input().split()
    ksm.append(ks)

pm = input().split()

ans = 0
for i in itertools.product([0, 1], repeat=switch):
    isOk = True
    for li in range(light):
        if not isOk:
            break
        p = int(pm[li])
        ks = ksm[li]
        light_sum = 0
        for ksi in range(int(ks[0])):
            light_sum += i[int(ks[ksi + 1]) - 1]
        if light_sum % 2 != p:
            isOk = False
    if isOk:
        ans += 1
print(ans)
# Buggy code:
N,M=map(int,input().split())

s=[[0 for i in range(N)] for j in range(M)]

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

    k=tmp[0]
    for j in range(k):
        s[i][tmp[j+1]-1]=1

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

out=0

for i in range(2**N):
    b=list(map(int,list(bin(i))[2:]))
    b=[0 * (N-len(b))]+b
    ss=1
    for j in range(M):
        t=0
        for k in range(N):
            if b[k]==s[j][k]:
                t+=1
        if t%2!=p[j]:
            ss=0
    if ss==1:
        out+=1

print(out)
       


# Fixed code:
N,M=map(int,input().split())

s=[[0 for i in range(N)] for j in range(M)]

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

    k=tmp[0]
    for j in range(k):
        s[i][tmp[j+1]-1]=1

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

out=0

for i in range(2**N):
    b=list(map(int,list(bin(i))[2:]))
    b=[0 for j in range((N-len(b)))]+b
    ss=1
    for j in range(M):
        t=0
        for k in range(N):
            if b[k]==1 and s[j][k]==1:
                t+=1
        if t%2!=p[j]:
            ss=0
    if ss==1:
        out+=1

print(out)
# Buggy code:
import sys
def dfs(A):
    global cnt

    if len(A) == n:
        ans = [0 for i in range(m)]
        print(A)
        for i, a in enumerate(A):
            if a:
                for j in range(m):
                    if i+1 in s[j]:
                        ans[j] += 1
        print(ans)
        for x, y in zip(p, ans):
            if x != y%2:
                break
        else:
            cnt += 1
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

n, m = map(int, input().split())
s = [list(map(int, x.split()))[1:]  for x in sys.stdin.readlines()]
p = list(map(int, input().split()))
cnt = 0
dfs([])
print(cnt)

# Fixed code:
def dfs(A):
    global cnt

    if len(A) == n:
        ans = [0 for i in range(m)]
        for i, a in enumerate(A):
            if a:
                for j in range(m):
                    if i+1 in s[j]:
                        ans[j] += 1
        for x, y in zip(p, ans):
            if x != y%2:
                break
        else:
            cnt += 1
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:]  for _ in range(m)]
p = list(map(int, input().split()))
cnt = 0
dfs([])
print(cnt)
# Buggy code:
import itertools
N = int(N)
M = int(M)
line_list = []
for i in range(M):
    line = input().split()
    new_list=[]
    for l in line:
        new_list.append(int(l))
    new_list.pop(0)
    line_list.append(new_list)
old_p_list = input().split()
p_list = []
for p in old_p_list:
    p_list.append(int(p))

A = []
for n in range(N):
    A.append([True,False])
pattern_list = list(itertools.product(*A))
pattern_num = 0
for pattern in pattern_list:
    ok_flug = 1
    for i, line in enumerate(line_list):
            on_num = 0
            for l in line:
                if pattern[l-1]:
                    on_num += 1
            if on_num%2 != p_list[i]:
                ok_flug = 0
    if ok_flug == 1:
        pattern_num += 1
print(pattern_num)

# Fixed code:
import itertools
N,M = input().split()
N = int(N)
M = int(M)
line_list = []
for i in range(M):
    line = input().split()
    new_list=[]
    for l in line:
        new_list.append(int(l))
    new_list.pop(0)
    line_list.append(new_list)
old_p_list = input().split()
p_list = []
for p in old_p_list:
    p_list.append(int(p))

A = []
for n in range(N):
    A.append([True,False])
pattern_list = list(itertools.product(*A))
pattern_num = 0
for pattern in pattern_list:
    ok_flug = 1
    for i, line in enumerate(line_list):
            on_num = 0
            for l in line:
                if pattern[l-1]:
                    on_num += 1
            if on_num%2 != p_list[i]:
                ok_flug = 0
    if ok_flug == 1:
        pattern_num += 1
print(pattern_num)
# Buggy code:
import itertools
n,m = map(int,input().split())
k = []
s = []
for i in range(m):
    temp = list(map(int,input().split()))
    k.append(temp[0])
    s.append(temp[1:])
p = list(map(int,input().split()))

z = list(itertools.combinations_with_replacement([1,0],n))
ans = 0
for i in z:
    ad = True
    for j in range(m):
        cnt = 0
        for l in range(k[j]):
            if i[s[j][l]-1] == 1:
                cnt += 1
        if not cnt%2 == p[j]:
            ad = False
            break
    if ad:
        ans += 1
print(ans)

# Fixed code:
import itertools
n,m = map(int,input().split())
k = []
s = []
for i in range(m):
    temp = list(map(int,input().split()))
    k.append(temp[0])
    s.append(temp[1:])
p = list(map(int,input().split()))

oz = [[1,0]]*n
z = list(itertools.product(*oz))
ans = 0
for i in z:
    ad = True
    for j in range(m):
        cnt = 0
        for l in s[j]:
            if i[l-1] == 1:
                cnt += 1
        if not cnt%2 == p[j]:
            ad = False
            break
    if ad:
        ans += 1
print(ans)
# Buggy code:
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 = 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 != 0 and c % 2 == p[j]:
            s += 1
    if s == m :
        ans += 1

print(ans)


# Fixed code:
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 = 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)
# Buggy code:
n, m = map(int, input().split())

lis = []
for _ in range(m):
    new = list(map(int, input().split()))
    lis.append(new[1:])

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

res = 0
for i in range(2**n):
    cou = [0 for k in range(m)]
    binary = bin(i)[2:]
    for j in range(len(binary)):
        if binary[j] == '1':
            for k in range(len(lis)):
                if j + 1 in lis[k]:
                    cou[k] += 1 
    if all((cou[x] - plist[x])%2 == 0 for x in range(m)):
        res += 1
print(res)

# Fixed code:
n, m = map(int, input().split())

lis = []
for _ in range(m):
    new = list(map(int, input().split()))
    lis.append(new[1:])

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

res = 0
for i in range(2**n):
    cou = [0 for k in range(m)]
    binary = '0'*(n - len(bin(i)[2:])) + bin(i)[2:]
    for j in range(n):
        if binary[j] == '1':
            for k in range(len(lis)):
                if j + 1 in lis[k]:
                    cou[k] += 1 
    if all((cou[x] - plist[x])%2 == 0 for x in range(m)):
        res += 1
print(res)