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()))

def main():
    mod=10**9+7
    N,M=MI()
    s=[]
    for i in range(M):
        L=LI()
        s.append(L[1:])
    p=LI()
    
    import itertools
    
    ans=0
    for ite in itertools.product([0,1], repeat=N):
        flag=1
        for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
        if flag:
            ans+=1
            
    print(ans)
                
                
            
        

main() 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 def main():
    mod=10**9+7
    N,M=MI()
    s=[]
    for i in range(M):
        L=LI()
        s.append(L[1:])
    p=LI()
    
    import itertools
    
    ans=0
    for ite in itertools.product([0,1], repeat=N):
        flag=1
        for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
        if flag:
            ans+=1
            
    print(ans)
                
                
            
         main mod=10**9+7 mod 10**9+7 10**9 10 9 7 N,M=MI() N MI() MI M s=[] s [] for i in range(M):
        L=LI()
        s.append(L[1:])
     i range(M) range M L=LI() L LI() LI s.append(L[1:]) s.append s append L[1:] L 1: 1 p=LI() p LI() LI import itertools itertools ans=0 ans 0 for ite in itertools.product([0,1], repeat=N):
        flag=1
        for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
        if flag:
            ans+=1
            
     ite itertools.product([0,1], repeat=N) itertools.product itertools product [0,1] 0 1 repeat=N repeat N flag=1 flag 1 for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
         i range(M) range M temp=0 temp 0 for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
             ss s[i] s i if ite[ss-1]:
                    temp+=1
             ite[ss-1] ite ss-1 ss 1 temp+=1 temp 1 if temp%2==p[i]:
                pass
            else:
                flag=0
         temp%2==p[i] temp%2 temp 2 p[i] p i flag=0 flag 0 if flag:
            ans+=1
            
     flag ans+=1 ans 1 print(ans) print ans main() main def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def I(): return int(input()) def I(): return int(input()) I input = sys.stdin.readline sys.stdin.readline input def main():
    mod=10**9+7
    N,M=MI()
    s=[]
    for i in range(M):
        L=LI()
        s.append(L[1:])
    p=LI()
    
    import itertools
    
    ans=0
    for ite in itertools.product([0,1], repeat=N):
        flag=1
        for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
        if flag:
            ans+=1
            
    print(ans)
                
                
            
         def main():
    mod=10**9+7
    N,M=MI()
    s=[]
    for i in range(M):
        L=LI()
        s.append(L[1:])
    p=LI()
    
    import itertools
    
    ans=0
    for ite in itertools.product([0,1], repeat=N):
        flag=1
        for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
        if flag:
            ans+=1
            
    print(ans)
                
                
            
         main
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()))

def main():
    mod=10**9+7
    N,M=MI()
    s=[]
    for i in range(M):
        L=LI()
        s.append(L[1:])
    p=LI()
    
    import itertools
    
    ans=0
    for ite in itertools.product([0,1], repeat=N):
        flag=1
        for i in range(M):
            temp=0
            for ss in s[i]:
                if ite[ss-1]:
                    temp+=1
            if temp%2==p[i]:
                pass
            else:
                flag=0
        if flag:
            ans+=1
            
    print(ans)
                
                
            
        

main()
