def main():
    N,M=map(int,input().split())

    k_list=[]
    swiches=[]
    for i in range(M):
        inp=list(map(int,input().split()))
        k_list.append(inp[0])
        swiches.append(inp[1:])
    P=list(map(int,input().split()))

    res=0
    for SwichStatus in range(pow(2,N)):
        flag=0
        for i in range(M):
            Link=0
            for swich in swiches[i]:
                Link+=1<<(swich-1)
            OnSwich=SwichStatus&Link
            OnCounter=0
            while OnSwich!=0:
                OnCounter+=OnSwich&1
                OnSwich>>=1
            if OnCounter%2!=P[i]:
                flag=1
                break
        if flag!=1:
            res+=1
    
if __name__=="__main__":
    main()

