Problem: Mitya and Vasya are playing an interesting game. They have a rooted tree with vertices, and the vertices are indexed from to . The root has index . Every other vertex has its parent , and vertex is called a child of vertex .
There are some cookies in every vertex of the tree: there are cookies in vertex . It takes exactly time for Mitya to eat one cookie in vertex . There is also a chip, which is initially located in the root of the tree, and it takes time to move the chip along the edge connecting vertex with its parent.
Mitya and Vasya take turns playing, Mitya goes first.
- Mitya moves the chip from the vertex, where the chip is located, to one of its children.
- Vasya can remove an edge from the vertex, where the chip is located, to one of its children. Vasya can also decide to skip his turn.
Mitya can stop the game at any his turn. Once he stops the game, he moves the chip up to the root, eating some cookies along his way. Mitya can decide how many cookies he would like to eat in every vertex on his way. The total time spent on descend, ascend and eating cookies should not exceed . Please note that in the end of the game the chip is always located in the root of the tree: Mitya can not leave the chip in any other vertex, even if he has already eaten enough cookies — he must move the chip back to the root (and every move from vertex to its parent takes time).
Find out what is the maximum number of cookies Mitya can eat, regardless of Vasya's actions.
Input Format: The first line contains two integers and — the number of vertices in the tree and the time he has to accomplish his task (; ).
The second line contains integers , , ..., — number of cookies located in the corresponding vertex (). The third line contains integers , , ..., — how much time it takes Mitya to eat one cookie in vertex ().
Each of the following lines describe the tree. For every from to , the corresponding line contains two integers and , where denotes the parent of vertex and denotes the time it takes Mitya to move the chip along the edge from vertex to its parent (, ).
Output Format: Output a single integer — maximum number of cookies Mitya can eat.
Note: In the first example test case, Mitya can start by moving the chip to vertex . In this case no matter how Vasya plays, Mitya is able to eat at least cookies. Below you can find the detailed description of the moves:
- Mitya moves chip to vertex .
- Vasya removes edge to vertex .
- Mitya moves chip to vertex .
- Since vertex has no children, Vasya does not remove any edges.
- Mitya stops the game and moves the chip towards the root, eating cookies along the way ( in vertex , in vertex , in vertex ).
Mitya spend time to go down, to go up, to eat cookies in vertex 5, to eat cookies in vertex 2, to eat cookie in vertex 1. Total time is .