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) import sys sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

#bit全部作ってる
#bit = [i>>j&1 for j in range(N)] LI n,m=MI() n MI() MI m LI() for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) LI() LI lights=[LI() for _ in range(m)] lights [LI() for _ in range(m)] p_list=LI() p_list LI() LI bit_list=[] bit_list [] count=0 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 i range(2**n) range 2**n 2 n i>>j&1 for j in range(n) for j in range(n) j range(n) range n for j in range(n) i>>j&1 i>>j i j 1 bit = [i>>j&1 for j in range(n)] bit [i>>j&1 for j in range(n)] flag=0 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
     j range(m) range m ki=lights[j][0] ki lights[j][0] [j] lights j 0 onswitch=0 onswitch 0 for k in range(1,ki+1):
            si=lights[j][k]
            onswitch+=bit[si-1]
         k range(1,ki+1) range 1 ki+1 ki 1 si=lights[j][k] si lights[j][k] [j] lights j k onswitch+=bit[si-1] onswitch bit[si-1] bit si-1 si 1 if onswitch%2!=p_list[j]:
            flag+=1
     onswitch%2!=p_list[j] onswitch%2 onswitch 2 p_list[j] p_list j flag+=1 flag 1 if flag==0:
        count+=1 flag==0 flag 0 count+=1 count 1 print(count) print count bit_list=[] [] bit_list p_list=LI() LI() p_list count+=1 1 count m=MI() MI() m onswitch+=bit[si-1] bit[si-1] onswitch def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

#bit全部作ってる
#bit = [i>>j&1 for j in range(N)] def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

#bit全部作ってる
#bit = [i>>j&1 for j in range(N)] LI def MI(): return map(int,sys.stdin.readline().rstrip().split()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI flag+=1 1 flag si=lights[j][k] lights[j][k] si n,m=MI() MI() n bit = [i>>j&1 for j in range(n)] [i>>j&1 for j in range(n)] bit count=0 0 count lights=[LI() for _ in range(m)] [LI() for _ in range(m)] lights ki=lights[j][0] lights[j][0] ki onswitch=0 0 onswitch flag=0 0 flag
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)