The first line of the input contains an integer $T$ $(1\leq T\leq 10)$, denoting the number of test cases.
In each test case, the first line of the input contains four integers $n$ $(1\leq n\leq 50),m(0\leq m\leq \frac{n(n-1)}{2}),K(0\leq K\leq 10^9),q(1\leq q\leq 125000)$, denoting the number of cities, the number of roads, the upper limit of interphone and the number of missions.
The second line of the input contains $n$ integers $w_1, w_2, ..., w_n$ $(1\leq w_i\leq 10^9)$, denoting the radio frequency of the $i$-th city.
Each of the next $m$ lines contains two integers $u_i,v_i$ $(1\leq u_i < v_i\leq n)$, denoting an one-way road. There are no multiple edges in the graph.
Each of the next $q$ lines contains three integers $x,y,z(1\leq x,y,z\leq n)$, denoting the starting point of the three spies in each mission. You can assume that there are at least one possible way in each mission.