A country consists of n cities and m one-way roads. There is a central city with number s. Each city sells a particular sweet (city i sells sweets of value v[i]).
You are required to go to city d. If you are currently in city x, then you can randomly select and move to one of the cities that is directly reachable from x through a single road. You can perform this technique until you reach city d. You must stop once you reach the destination city.
You can buy sweets only once on your way. Determine the highest value p such that you can take home a sweet whose value is at least p independent of the path that you take. Print the value of p for each destination city d from 1 to n.
Note
Input format
Output format
For each test case, print n space-separated integers denoting the answer to each destination city.
Constraints
1≤t≤3
1≤n,u,v,s≤105
1≤m≤2∗105
1≤v[i]≤106
In the second testcase:
There is only one path for reaching city 1, and he will buy sweets of value 6 in city 1. There is also only one path for reaching city 4 and he will buy sweets of value 5 from city 4. There are two paths 2->4->3 and 2->1->3 for reaching city 3. In the first path he can buy sweets of value 5 from city 4 and in the second path he can buy sweets of value 6 from city 1. So he can take sweets of value at least 5 if the destination city is 3.