Under construction

Still being built. Things may change

Dragging

Time limit2.5sMemory limit256 MB

Summary
Two players take turns dragging each other along a road graph for K hours, one maximizing and one minimizing the saltiness of the final dish. Find that saltiness.
Level

Medium7 of 10

Topics
Dynamic programming, Graph, BFS
Solved
No attempts yet

Statement

Taeyoung and Seunghan went abroad for the year-end holiday. While wandering around, they realized that lunchtime was not far away.

Lunchtime starts in exactly KK hours. The two want to eat at the best restaurant they can reach. The problem is that their food tastes are opposite. Taeyoung likes food that is saltier, and Seunghan likes food that is less salty.

The town has NN restaurants connected by MM roads. Every road takes exactly 10 minutes to travel. Two restaurants may be connected by more than one road, and a road may start and end at the same restaurant. Each restaurant sells exactly one dish. The saltiness of the dish at restaurant ii is the integer CiC_i.

Neither of them is willing to give in, and their strength is evenly matched. So for the remaining KK hours, they move according to these rules. For the first 20 minutes, Taeyoung drags Seunghan along. For the next 10 minutes, Seunghan drags Taeyoung along. For the next 10 minutes, Taeyoung drags Seunghan along. For the next 20 minutes, Seunghan drags Taeyoung along. These four steps repeat until KK hours have passed. For example, with 120 minutes left, the four steps run twice, giving (20+10+10+20)+(20+10+10+20)(20+10+10+20)+(20+10+10+20) minutes.

During the time a person is dragging the other, that person may stay still. However, at the end of each turn, both must be at a restaurant. They cannot stop halfway along a road.

Both have a map of the town and move under the rules above, choosing whatever is best for themselves. Taeyoung moves toward the dish with the highest saltiness he can reach, and Seunghan moves toward the dish with the lowest saltiness he can reach. They are currently at restaurant 1. Find the saltiness of the dish that Taeyoung and Seunghan end up eating.

Input

The first line contains NN, MM, and KK separated by spaces. (1≤N≤2×1051 \le N \le 2 \times 10^5, 0≤M≤5×1050 \le M \le 5 \times 10^5, 0≤K≤5×1050 \le K \le 5 \times 10^5)

The second line contains C1,C2,…,CNC_1, C_2, \ldots, C_N separated by spaces. (0≤Ci≤1090 \le C_i \le 10^9)

From the third line through line M+2M+2, each line contains two positive integers SiS_i and EiE_i, meaning restaurant SiS_i and restaurant EiE_i are connected by a road. (1≤Si,Ei≤N1 \le S_i, E_i \le N)

Output

Print the saltiness of the dish that Taeyoung and Seunghan end up eating on the first line.

Examples1

  1. Example 1

    Input
    5 4 3
    3 6 7 2 8
    1 2
    2 3
    3 4
    4 5
    
    Expected output
    3