Sightseeing

No attempts yetTime limit3.5sMemory limit512 MB

Problem

Tourist sites are nodes and roads are bidirectional edges with quality values. A path quality is the minimum edge quality on the path. The hotel is node 1. For each destination, print the maximum achievable path quality from node 1.

Input

The first line contains ,, , and .Eachofthenext. Each of the next lines has endpoints ,, and quality (q100000 (-- \le q \le 100000). Each of the next lineshasadestinationlines has a destination with
e 1$.

Output

For each destination, print one line with the highest achievable path quality.

Constraints

\le 500000,5000000, \le 5000000, \le V-1$