
if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    ks = []
    bitnums = []
    for i in range(m):
        ks.append(list(map(int, input().split())))
        bitnum = 0
        for j in range(1, ks[i][0]+1):
            bitnum += 1 << (ks[i][j]-1)
        bitnums.append(bitnum)
    p = list(map(int, input().split()))

    np = [1] * (2**n)
    np[0] = 0

    for i in range(1, len(np)):
        for j in range(m):
            cnt = bin(i & bitnums[j]).count("1")
            #if(cnt == 0):
            #    np[i] = 0
            #    break
            if(cnt % 2 != p[j]):
                np[i] = 0
                break
    
    #for i in range(len(np)):
    #    print("{0} {1}".format(np[i], bin(i)))
        
    print(sum(np))
