Friendship Fee

Interview

Time limit2sMemory limit512 MB

Summary
Find the cheapest way to become friends with everyone by paying each student a friend fee and using the friend-of-a-friend rule; output the minimum cost or "Oh no" when it exceeds k.
Level

Medium5 of 10

Topics
Union-find, Graph, Greedy
Solved
No attempts yet

Problem

Lee Junseok, admitted in the class of 2019, has entered a school with NN students. Wanting to mark his admission, Junseok wants to become friends with every student. But Junseok has spent his whole life talking only to computers, so he does not know how to speak with people. Even for Junseok there is hope. It is the friendship fee!

If you give student ii an amount AiA_i of money, that student will be your friend for one month. Junseok has a total of kk won, and he decided to use that money to make friends. As he actually went about making friends, he began to think that he would run out of money. So Junseok decided to use the rule "a friend of a friend is a friend".

Now Junseok does not have to pay every friend!

Using this logic, find the way to become friends with everyone at the lowest cost.

Input

The first line gives the number of students NN (1≤N≤10,0001 \le N \le 10,000), the number of friend relations MM (0≤M≤10,0000 \le M \le 10,000), and the money Junseok has, kk (1≤k≤10,000,0001 \le k \le 10,000,000).

The second line gives the friendship fee AiA_i that each of the NN students wants. (1≤Ai≤10,0001 \le A_i \le 10,000, 1≤i≤N1 \le i \le N)

The next MM lines give numbers v,wv, w. This means student vv and student ww are friends with each other. A student may be friends with themselves, and the same friend relation may be given multiple times.

Output

If Junseok can make every student his friend, print the minimum cost of making them friends. If he cannot make friends with all of them, print “Oh no” (without the quotation marks).

Examples2

  1. Example 1

    Input
    5 3 20
    10 10 20 20 30
    1 3
    2 4
    5 4
    
    Expected output
    20
    
  2. Example 2

    Input
    5 3 10
    10 10 20 20 30
    1 3
    2 4
    5 4
    
    Expected output
    Oh no