URI Online Judge | 1762

Sleds of Santa Claus

By Julio Cesar Ceron, URI Oline Judge BR Brazil

Timelimit: 1

Every year during Christmas season, Santa Claus has the important and difficult task of delivering thousands of gifts to all the children around the world. What no one knows is that he developed an effective way to be able to deliver all the presents before Christmas is over, and that way is a plethora of sleds around the globe simultaneously delivering all the gifts. This way is much easier to complete deliveries, but because there is an enormous number of gifts to be delivered, Santa always has difficulties in knowing how many sleds he will provide for each lot of gifts. Santa has a list with the number of gifts each batch containing the present name and its weight, and he also knows the carrying capacity of each sled. Knowing this information, every year, Santa asks help from a student to develop a program that can help him know how many sleds will be required for each lot.

Your task is to develop a program that stores a number of gifts of a lot, each gift is stored with the name of the toy and its respective weight in Kilograms (consider two digits after decimal point), after that you will have the capacity of each sled, and after you will have the order list wich contains the name of the gift and its amount, done that you should calculate the total weight of the gift and determine how many sleds will be required to make the delivery.

Input

The first line contains an integer Y indicating the amount of test cases, followed by an integer T (0 < T <1000) corresponding to the number of gifts in the batch, after you must readf the gift list, a string N with the gift name and a floating point value K (0 < K ≤ 100) that corresponds to the weight in kilograms of it, the name and weight will be on separate lines. After entering all T gifts the next value is a floating point value M (0 < M ≤ 100) corresponding to the sled carrying capacity in kilograms, consider two digits after decimal point. After inserting the M value the next part is the list containing X applications as follows, a string P corresponding to the gift name, the next line an integer value J (0 < J ≤ 100) representing the quantity of each gift. This list just ends when a "-" is read for the gift name and "0" for the gift weight.

Output

In the first line of output should be informed of the total weight of all gift in the wish list, with two places after the decimal point. In the second line will be told the number of sleds necessary to get the gifts on the wish list. If inserted in the request list a gift that is not in the batch list of toys, the following message should be printed “NAO LISTADO: ” followed by this name.

Leave a blank line after printing each test case.

Input Samples Output Samples

2
5
Martelo do Thor
0.50
Bicicleta do Ben10
12.0
Boneco do Wolverine
0.90
Carrinho de controle remoto
0.50
Mascara do Homem de Ferro
2.50
60.00
Mascara do Homem de Ferro
55
Bicicleta do Ben10
30
Mascara do Homem de Ferro
32
Boneco do Wolverine
60
Carrinho de controle remoto
80
Mascara do Homem de Ferro
25
-
0
5
Comandos em Acao
1.50
Boneco do Batman
0.8
Carrinho de madeira
2.90
Tenis do Flash
5.50
Mochila do X-men
0.90
100.00
Carrinho de madeira
50
Mochila do X-men
30
Tenis do Flash
12
Boneco do Batman
30
Comandos em Acao
30
Boneco do Homem Aranha
10
-
0

Peso total: 734.00 kg
Numero de trenos: 13


NAO LISTADO: Boneco do Homem Aranha
Peso total: 307.00 kg
Numero de trenos: 4