Firdaws and Fatinah are living in a country with nnn cities, numbered from 111 to nnn. Each city has a risk of kidnapping or robbery.
Firdaws's home locates in the city uuu, and Fatinah's home locates in the city vvv. Now you are asked to find the shortest path from the city uuu to the city vvv that does not pass through any other city with the risk of kidnapping or robbery higher than www, a threshold given by Firdaws.
Input
The input contains several test cases, and the first line is a positive integer TTT indicating the number of test cases which is up to 505050.
For each test case, the first line contains two integers n(1≤n≤200)n (1 \le n \le 200)n(1≤n≤200) which is the number of cities, and q(1≤q≤2×104)q (1 \le q \le 2 \times 10^4)q(1≤q≤2×104) which is the number of queries that will be given. The second line contains nnn integers r1,r2,⋯ ,rnr_1, r_2, \cdots , r_nr1,r2,⋯,rn indicating the risk of kidnapping or robbery in the city 111 to nnn respectively. Each of the following nnn lines contains nnn integers, the jjj-th one in the iii-th line of which, denoted by di,jd_{i,j}di,j, is the distance from the city iii to the city jjj.
Each of the following qqq lines gives an independent query with three integers u,vu,vu,v and www, which are described as above.
We guarantee that 1≤ri≤105,1≤di,j≤105(i≠j),di,i=01 \le r_i \le 10^5, 1 \le d_{i,j} \le 10^5 (i \neq j), d_{i,i} = 01≤ri≤105,1≤di,j≤105(i=j),di,i=0 and di,j=dj,id_{i,j} = d_{j,i}di,j=dj,i. Besides, each query satisfies 1≤u,v≤n1 \le u,v \le n1≤u,v≤n and 1≤w≤1051 \le w \le 10^51≤w≤105.
Output
For each test case, output a line containing Case #x: at first, where xxx is the test case number starting from 111. Each of the following qqq lines contains an integer indicating the length of the shortest path of the corresponding query.
输出时每行末尾的多余空格,不影响答案正确性
样例输入
1
3 6
1 2 3
0 1 3
1 0 1
3 1 0
1 1 1
1 2 1
1 3 1
1 1 2
1 2 2
1 3 2
样例输出
Case #1:
0
1
3
0
1
2
Firdaws and Fatinah are living in a country with nnn cities, numbered from 111 to nnn. Each city has a risk of kidnapping or robbery.Firdaws's home locates in the city uuu, and Fatinah's home locate...