Hokusai Artworks

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

There are NN cities on some Japanese island and MM one-directional roads connecting those cities. Each city has a museum which is open at even days and is closed at odd days. Museum of ii-th city holds w_iw\_i Hokusai artworks.

Bytika arrived on the main city of the island (whis is placed at city 0) at the morning of an even day. Each day, she visits the museum in the current city (if the museum is open on that day and if she did not visit this museum before), and moves overnight to another city (possibly one she already visited) by using any one road leading from the current city. If Bytika cannot leave the current city, or if here are no chances to see new Hokusai artworks, she leaves the island by plane.

Find the maximum number of Hokusai artworks Bytika can see.

입력

The first line of input contains two integers nn and mm (1n1051 \le n \le 10^5, 0mmin(n(n1),105)0 \le m \le \min (n \cdot (n - 1), 10^5)): the number of cities and the number of roads. The second line contains nn integers w_0w\_0, w_1w\_1, \ldots, w_n1w\_{n - 1}; ii-th of those integers is the number of Hokusai artworks in the museum of ii-th city (0w_i10000 \le w\_i \le 1000). Each of next mm lines contains two integers s_js\_j and t_jt\_j denoting that there is a one-directional road from city s_js\_j to city t_jt\_j (0s_j,t_jn10 \le s\_j, t\_j \le n - 1, s_jt_js\_j \ne t\_j, (s_j,t_j)(s_i,t_i)(s\_j, t\_j) \ne (s\_i, t\_i) if iji \ne j).

출력

Print one integer: the maximum number of distinct Hokusai artworks Bytika can see while traveling on the island.