Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 102400/65535 K (Java/Others)


Brickgao, who profited from your accurate calculating last year, made a great deal of money by moving bricks. Now he became ``gay shy fool'' again and recently he bought an iphone and was deeply addicted into a cellphone game called Ingress. Now he is faced with a problem so he turns to you for help again. We make some slight modifications based on the original rules, so please draw attention to the details below.

There are $N$ portals (indexed from 1 to $N$) around Brickgao's home, and he can get some substances called XM by hacking the portals. It's known that for each portal $i$, he can get $A_i$ XM during the first hack, and after each hack, the amount of XM he will get during the next hack will decrease by $B_i$. If the amount of XM he can get is less than or equal to zero, Brickgao can't get XM from that portal anymore. For the $i$-th portal, if $A_i = 10, B_i = 2$ and he hacks 3 times, he will get 10, 8, 6 XM during each hack.

There are $M$ bidirectional roads between some pairs of portals and between Brickgao's home and some portals. Now he is eager to start his Ingress journey from home and finally return home, but due to the extremely hot weather, Brickgao will feel sick when you hack more than $K$ times or the distance he covers is more than $L$. So how much XM he can get at most during this journey?


The first line contains a single integer $T(T\leq 20)$, indicating the number of test cases.

The first line of each case are four integers $N(1\leq N \leq 16), M(0 \leq M \leq \frac{N(N+1)}{2}), K(1 \leq K \leq 50)$ and $L(2 \leq L \leq 2000)$.
The second line of each case contains $N$ non-negative integers where the $i$-th denotes $A_i(A_i \leq 500)$.
The third line of each case contains $N$ non-negative integers where the $i$-th denotes $B_i(B_i \leq 50)$.
Each of next $M$ line contains 3 non-negative integers $u, v ( 0\leq u,v\leq n)$ and $c (0\leq c\leq 1000)$ , denotes that there is a road with the length of $c$ between the $u$-th and the $v$-th portal. If $u$ or $v$ equals to 0, it means Brickgao's home.


For each test case, output the case number first, then the amount of maximum XM Brickgao can get.

Sample Input

2 1 1 3 2 5 3 0 1 1 3 6 3 5 10 7 5 2 3 1 0 1 3 0 2 1 0 3 1 1 2 2 2 3 3 1 3 4

Sample Output

Case 1: 7 Case 2: 16




"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场