Peaks

No attempts yetTime limit2sMemory limit128 MB

Problem

Byteasar works at the visitor center of Bytemountains National Park. Bytemountains has nn peaks, and some pairs of peaks are joined by trails of varying difficulty.

Tourists keep asking Byteasar the same kind of question: starting from a given peak and walking only along trails whose difficulty does not exceed a chosen limit, what is the height of the kk-th highest peak that can be reached?

A peak is reachable from the starting peak when you can walk to it along a sequence of trails, each with difficulty at most the given limit. The starting peak itself is always considered reachable. Help Byteasar answer every question.

Input

The first line contains three integers nn, mm, and qq (1n1000001 \le n \le 100000, 1m,q5000001 \le m, q \le 500000): the number of peaks, the number of trails, and the number of questions. Peaks are numbered from 11 to nn.

The second line contains nn integers h1,h2,,hnh_1, h_2, \dots, h_n (1hi1091 \le h_i \le 10^9), the height of each peak.

Each of the next mm lines contains three integers aa, bb, and cc (1a,bn1 \le a, b \le n, aba \ne b, 1c1091 \le c \le 10^9), describing a bidirectional trail between peaks aa and bb with difficulty cc; a larger cc means a harder trail. Two peaks may be joined by more than one trail.

Each of the next qq lines contains three integers vv, xx, and kk (1vn1 \le v \le n, 1x1091 \le x \le 10^9, 1kn1 \le k \le n): starting from peak vv and using only trails of difficulty at most xx, report the height of the kk-th highest reachable peak.

Output

Print qq lines. The ii-th line must hold the answer to the ii-th question: the height of the kk-th highest peak reachable under that question's conditions. If fewer than kk peaks are reachable, print 1-1 instead.