import sys
import math
import itertools


def main():
    N,M = map(int,input().split())
    S={}
    P=[0] * (M+1)
    List=[]
    for i in range(1,M+1):
        array = list(map(int, input().split()))
        for s in range(1,len(array)):
            #print(s)
            if i in S.keys():
                S[i].append(array[s])
            else:
                S[i]=[]
                S[i].append(array[s])

    array = list(map(int, input().split()))
    for i in range(1,M+1):
        P[i]=array[i-1]

    for i in range(N):
        List.append(i+1)

    comb=[]
    count=0
    for i in range(1,N+1):
        for l in itertools.combinations(List,i):
            comb=l       
            flag=-1
            for j in range(1,M+1):
                
                cnt=0
                for k in range(0,len(comb)):
                    if comb[k] in S[j]:
                        cnt+=1
                if cnt%2==P[j]:
                    flag=1
                else:
                    flag=-1
                    break
            if flag==1:
                #print(comb)
                count+=1
    print(count)
                    
                               
if __name__ == "__main__":
    main()


  












