How many journeys has Blind Pew seen in his life... How many gold coins has he held in his hands... How many times has he gotten into trouble... No, you can’t just take and end a pirate’s career! Therefore, Blind Pew has gathered a crew of crazy sailors again and set off in search of new adventures.
In the pirate world, there are n islands with treasures. Island number i holds a chest with ai piastres. Between the islands, there are m sea routes that allow movement between them. The islands and routes form an undirected graph, where each sea route connects two different islands.
The popularity of an island is determined by the number of sea routes connecting it to other islands. A journey is a sequence of islands such that there is a sea route between each pair of consecutive islands, and the popularity of each subsequent island is strictly greater than the popularity of the previous one. The length of a journey is the number of sea routes in it.
At the beginning, Blind Pew and his crew are on island number 1, where they have already found a chest with a1 piastres. The pirates can start any journey from the current island but only stop at the last island of the journey and open the chest there (the chests of intermediate islands remain untouched). All the gold Pew collects in his pocket. Each new journey starts from the island where the previous one ended.
Each journey requires payment to the crew. If the length of the journey is i, then the crew will demand bi piastres for it. Pew pays the crew the total amount for all journeys at the end of the last one. If Pew and his crew do not make any journeys, then Pew does not pay his crew anything.
Blind Pew wants to earn as many piastres as possible by making several journeys (possibly none). Help him find the maximum number of piastres he can earn.
Input
The first line contains two numbers n and m — the number of islands and the number of sea routes respectively (2 ≤ n ≤ 105, 1 ≤ m ≤ 105).
The second line contains a sequence of n numbers a1, a2, …, an, where ai — the number of piastres on island number i (1 ≤ ai ≤ 109).
The third line contains a sequence of n − 1 numbers b1, b2, …, bn−1, where bi — the cost of a journey of length i (1 ≤ bi ≤ 109).
In the following m lines, there are two numbers u and v — the numbers of the islands between which there is a sea route (1 ≤ u, v ≤ n, u ≠ v).
It is guaranteed that there is at most one sea route between any two islands (no multiple edges).
Output
In the output, print a single number — the maximum number of piastres that Blind Pew can earn by making several journeys.
Sample
input | output |
---|
6 10
5 6 8 2 5 7
3 5 2 4 6
1 2
1 3
1 4
2 3
2 4
2 5
3 4
3 6
4 5
4 6 | 10 |
Notes
In the first example, the most profitable option is to make a single journey of length 1 to island 3. In this case, Pew will receive (5 + 8) − 3 = 10 piastres.
Problem Author: Artyom Abaturov
Problem Source: Ural School Programming Contest 2024