Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

SPSE - Space Shuttle Experiments

Hiện tại, bài tập này đã có trên online judge chính thức của VNOI, bạn có thể truy cập ở đây: https://oj.vnoi.info/problem/spse


Professor Spook is consulting for NASA, which is planning a series of space shuttle flights and must decide which commercial experiments to perform and which instruments to have on board each flight. For each flight NASA considers a set E = {E1, E2, ..., Em} of instruments experiments and the commercial sponsor of Ej has agreed to pay NASA pj dollars for the results of the experiments.

The experiments use a set I = {I1, I2, ..., In} of instruments; each experiment Ej requires some of the instruments from the set. The cost of carrying instruments Ik is ck dollars. And an instrument can be used for multiple experiments.

The professor's job is to determine which experiments to perform and which instruments to carry for a given flight in order to maximize the net revenue, which is the total income from the experiments performed minus the total cost of the instruments carried. Since he is not a programmer, he asked your help.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing two integers m (1 ≤ m ≤ 1000) and n (1 ≤ n ≤ 1000), where m denotes the number of experiments and n denotes the number of instruments. The next line contains m space separated integers, where the jth integer denotes the commercial sponsor of Ej paying NASA p(1 ≤ pj ≤ 10000) dollars for the result of the experiment. The next line contains n space separated integers, where the kth integer denotes the cost of carrying the kth instrument, c(1 ≤ ck ≤ 10000). Each of the next m lines contains an integer qi (1 ≤ qi ≤ n) followed by qi distinct integers each between 1 and n, separated by spaces. These qi integers denote the required instruments for the ith experiment.

Output

For each case, print the case number and the maximum revenue NASA can make using the experiments.

Sample Input

Output for Sample Input

2

1 1

10

20

1 1

3 5

20 30 40

1 2 30 4 50

3 1 2 3

3 2 3 4

1 5

Case 1: 0

Case 2: 13

 


Được gửi lên bởi:Race with time
Ngày:2012-12-04
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ASM64 GOSU PERL6 PYPY RUST SED

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.