import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return 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) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI n,m=MI() n MI() MI m sws=[] sws [] for i in range(m):
    sws.append(list(map(int,input().split())))
#print(sws) i range(m) range m sws.append(list(map(int,input().split()))) sws.append sws append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ps=LI() ps LI() LI ans=0 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 i range(2**n) range 2**n 2 n count=0 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
     j range(m) range m sm=0 sm 0 for k in range(1,len(sws[j])):
            sm+= (i>>(sws[j][k]-1)) %2
        #print(sm)
         k range(1,len(sws[j])) range 1 len(sws[j]) len sws[j] sws j sm+= (i>>(sws[j][k]-1)) %2 sm (i>>(sws[j][k]-1)) %2 i>>(sws[j][k]-1) i sws[j][k]-1 sws[j][k] [j] sws j k 1 2 if sm%2==ps[j]:
            count+=1
     sm%2==ps[j] sm%2 sm 2 ps[j] ps j count+=1 count 1 if count==m:
        ans+=1 count==m count m ans+=1 ans 1 print(ans) print ans count=0 0 count def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI ps=LI() LI() ps input = sys.stdin.readline sys.stdin.readline input sws=[] [] sws n,m=MI() MI() n ans=0 0 ans count+=1 1 count def I(): return int(input()) def I(): return int(input()) I sm+= (i>>(sws[j][k]-1)) %2 (i>>(sws[j][k]-1)) %2 sm sm=0 0 sm m=MI() MI() m ans+=1 1 ans def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return 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)
