#graph104. ATM
ATM
ATM
Problem Source
APIO 2009
Problem Description
The roads in the city of Siruseri are all one-way, and different roads connect at intersections. By law, every intersection has a Siruseri Bank ATM installed. Strangely, Siruseri's bars are also located at intersections, though not every intersection has a bar.
Banditji plans to carry out the most earth-shaking ATM robbery in the history of Siruseri. He will start from the city center, drive along the one-way roads, rob every ATM he passes, and finally celebrate his victory at a bar. Using superb hacking skills, he learned the amount of cash that can be grabbed from each ATM. He wants you to help him compute the maximum total cash he can rob by the time he reaches some bar, starting from the city center. He may pass through the same intersection or road any number of times, but once he has robbed an ATM, it will have no more money left in it.
Find the maximum total cash he can rob.
Input Format
The first line contains two integers (). is the number of intersections and is the number of roads.
The next lines each contain two integers (both between and ); the two integers on the -th line are the start and end intersection numbers of the -th road.
The next lines each contain one integer, giving the amount of money in the ATM at each intersection in order. Each ATM is guaranteed to hold a non-negative integer amount not exceeding .
The next line contains two integers , where is the index of the city center (the starting intersection) and is the number of bars.
The following line contains integers, the indices of the intersections that have bars.
The input guarantees that you can reach at least one bar from the city center along the one-way roads of Siruseri.
Output Format
Output one integer: the maximum total cash Banditji can rob, starting from the city center and ending at some bar.
Sample Input
6 7
1 2
2 3
3 5
2 4
4 1
2 6
6 5
10
12
8
16
1
5
1 4
4
3
5
6
Sample Output
47
Constraints
- ATM amounts are non-negative integers