Hirak Raja, the king of the country “Hirak Rajar Desh”, the conqueror ultimate, wanted to expand his kingdom. So, he decided to attack the Goopy kingdom. The Goopy kingdom consists of islands (numbered from 1 to ) and bridges. Each island has a leader with a leadership value . Each bridge connects two different islands and it is possible to travel from any island to any other island within the Goopy kingdom using the bridges.
Hirak Raja wanted to conquer some islands from the Goopy kingdom. To conquer an island, Hirak Raja has to capture the leader of that island. Hirak Raja started his mission from island . After conquering an island, he uses a bridge to move to another island that has not been conquered yet. He continues his mission for a while. After reaching island , he stops and comes back to Hirak Rajar Desh with the captured leaders. Hirak Raja’s prison has cells in which he has to put those captured leaders. Each cell can contain an infinite amount of prisoners. He will put the leaders into cells in such a way that they cannot plan any conspiracy against him.
In cell , if the maximum leadership value amongst leaders is and the minimum is , then the probability that a conspiracy is forming within that cell is . The probability that Hirak Rajar Desh is in danger is: . That means the maximum of all . As Hirak Raja wants to save his throne, he will put the leaders in cells in such a way that the probability of his kingdom being in danger is minimized.
You have to answer different queries. Each query consists of 3 integers , , and . You have to find out the probability that Hirak Rajar Desh is in danger if he started his attack from island and ended in island and there are cells in the prison.
Input starts with two integers () denoting the number of islands and number of queries to be answered.
The next lines contain integers each, denoting there is a bridge between island and island .
The next line contains integers, the leadership values (.
The next lines contain one query each. Each query consists of 3 integers , and ( ) as described above.
Reminder: Dataset is huge. Please consider using faster I/O methods.
For each query, print the probability that Hirak Raja’s kingdom is in danger. You have to print the probability in percentage. For example, if the probability is 0.37, you have to print 37%.
6 3 1 2 1 4 1 3 3 5 3 6 1 2 3 4 5 6 1 6 2 2 5 3 2 3 3
2% 1% 0%