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:
        check=0
        check_2=0
        for j in range(m):
            for k in range(swich[j][0]):
                check += i[swich[j][k]-1]
            if check%2 ==check_p[j]:
                check_2 +=1
        if check_2 ==m:
            cnt+=1
    print(cnt)

main()