CSES - Aalto Competitive Programming 2024 - wk12 - Mon - Chain Reaction
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Uoveli models interactions between atomic nuclei in a nuclear reaction as trees.

Each nucleus ii has two characteristics:

  • aia_i: the number of neutrons.
  • bib_i: the number of protons.

When nucleus ii interacts with nucleus jj, a charge transfer occurs from ii to jj. This charge can change in one of two ways:

  • It increases by ajaia_j - a_i.
  • It increases by bjbib_j - b_i.

During an experiment, Uoveli initially transfers a charge of 11 to a nucleus with index ss. 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 nn and ss:

  • nn: the number of atomic nuclei in the interaction tree.
  • ss: the index of the nucleus that initially receives the charge.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n, numbers of neutrons.
The third line contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n, numbers of protons.
The next n1n - 1 lines describe the interactions between the nuclei. Each line contains two integers uu and vv, indicating an interaction between nucleus uu and nucleus vv.

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

  • 1sn1051 \le s \le n \le 10^5
  • 1ai,bi1091 \le a_i, b_i \le 10^9
  • 1u,vn1 \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