- Time limit: 1.00 s
- Memory limit: 512 MB
Uoveli models interactions between atomic nuclei in a nuclear reaction as trees.
Each nucleus i has two characteristics:
- a_i: the number of neutrons.
- b_i: the number of protons.
When nucleus i interacts with nucleus j, a charge transfer occurs from i to j. This charge can change in one of two ways:
- It increases by a_j - a_i.
- It increases by b_j - b_i.
During an experiment, Uoveli initially transfers a charge of 1 to a nucleus with index s. This charge then propagates through the interaction tree to all other nuclei such that during each interaction, the charge changes according to one of the two rules mentioned above.
The scientist wants to determine the maximum possible charge that any nucleus in the interaction tree can achieve. Help him find this value.
Input
The first line contains two integers n and s:
- n: the number of atomic nuclei in the interaction tree.
- s: the index of the nucleus that initially receives the charge.
The second line contains n integers a_1, a_2, \dots, a_n, numbers of neutrons.
The third line contains n integers b_1, b_2, \dots, b_n, numbers of protons.
The next n - 1 lines describe the interactions between the nuclei. Each line contains two integers u and v, indicating an interaction between nucleus u and nucleus v.
It is guaranteed that the interaction graph is connected and forms a tree.
Output
Output a single integer: the maximum charge that any nucleus can achieve as a result of the experiment.
Constraints
- 1 \le s \le n \le 10^5
- 1 \le a_i, b_i \le 10^9
- 1 \le u, v \le n
Example
Input:
5 1 1 2 3 4 5 5 4 3 2 1 1 2 2 3 2 4 2 5
Output:
5