main = do
    pstr <- getLine
    let (n : q : _) = map read (words pstr)
    es <- mapM (const readEdge) [1 .. pred n]
    let mchildren = Map.fromListWith (Seq.><) (map (\(a, b) -> (b, Seq.singleton a)) es)
    let children = buildArr listArray 1 n (\_ x -> Fld.toList $ if x `Map.member` mchildren then fromJust $ x `Map.lookup` mchildren else Seq.empty)
    let ranks = buildArr U.listArray 1 n (\mem x -> Fld.foldl' (+) 0 ((\x -> succ $ mem x) `map` (children ! x)))
    sstr <- getLine
    let sals = U.listArray (1 :: Int, n) (map (read :: String -> Int) (words sstr))
    tst q 0 children sals

--f x children sals = merge (sort $ (\x -> (sals ! x, x)) `map` (children ! x)) $ foldl' merge [] ((\x -> f x children sals) `map` (children ! x))
main = do
    pstr <- getLine
    let (n : q : _) = map read (words pstr)
    es <- mapM (const readEdge) [1 .. pred n]
    let mchildren = Map.fromListWith (Seq.><) (map (\(a, b) -> (b, Seq.singleton a)) es)
    let children = buildArr listArray 1 n (\_ x -> Fld.toList $ if x `Map.member` mchildren then fromJust $ x `Map.lookup` mchildren else Seq.empty)
    let ranks = buildArr U.listArray 1 n (\mem x -> Fld.foldl' (+) 0 ((\x -> succ $ mem x) `map` (children ! x)))
    sstr <- getLine
    let sals = U.listArray (1 :: Int, n) (map (read :: String -> Int) (words sstr))
    tst q 0 children sals

--f x children sals = merge (sort $ (\x -> (sals ! x, x)) `map` (children ! x)) $ foldl' merge [] ((\x -> f x children sals) `map` (children ! x))
main = do
    pstr <- getLine
    let (n : q : _) = map read (words pstr)
    es <- mapM (const readEdge) [1 .. pred n]
    let mchildren = Map.fromListWith (Seq.><) (map (\(a, b) -> (b, Seq.singleton a)) es)
    let children = buildArr listArray 1 n (\_ x -> Fld.toList $ if x `Map.member` mchildren then fromJust $ x `Map.lookup` mchildren else Seq.empty)
    let ranks = buildArr U.listArray 1 n (\mem x -> Fld.foldl' (+) 0 ((\x -> succ $ mem x) `map` (children ! x)))
    sstr <- getLine
    let sals = U.listArray (1 :: Int, n) (map (read :: String -> Int) (words sstr))
    tst q 0 children sals

--f x children sals = merge (sort $ (\x -> (sals ! x, x)) `map` (children ! x)) $ foldl' merge [] ((\x -> f x children sals) `map` (children ! x))