import itertools

def main():
    n,m=list(map(int,input().split(' ')))
    swich_all=list(itertools.product([0,1],repeat=n))
    swich=[]
    cnt=0
    for i in range(m):
        swich.append(list(map(int,input().split(' '))))
    check_p=list(map(int,input().split(' ')))
    for i in swich_all:
        tmp=0
        check =True
        for j in range(m):
            for k in swich[j][1:]:
                tmp += i[k-1]
            if tmp%2 != check_p[j]:
                check = False
                break
        if check == True:
            cnt +=1

    print(cnt)

main()