Discounts

No attempts yetTime limit1sMemory limit128 MB

Problem

Peter's shop is doing poorly, so he is looking for ways to improve sales. His latest idea is a "buy three, get one free"-style promotion, and he hopes that special offers like this will bring more customers into his shop. Your task is to write a program that helps Peter's customers easily see how much they can save.

Input

The input contains several product scenarios.

Each scenario begins with the product's name on a line by itself. A name is made up of one or more words separated by spaces. A line containing only a single # marks the end of the input; do not process that entry.

The next line contains two integers $PD$ and $PC$ ($0 \le PD \le 50$, $0 \le PC \le 99$) separated by a space: the price of one item, in dollars and cents respectively. $PD$ and $PC$ are never both zero.

The next line contains one integer $D$ ($0 < D \le 10$): the number of offers available for this product. It is followed by $D$ lines, each containing two integers $B$ and $F$ ($0 < B, F \le 100$) separated by a space. $B$ is the number of items that must be bought, and $F$ is the number of items that may then be taken for free.

The next line contains one integer $E$ ($0 < E \le 30$): the number of queries that follow. Each of the next $E$ lines contains a single positive integer less than $500$, the quantity of items the customer wants. Using the available offers, determine the greatest saving the customer can make. Remember that a customer does not have to take every free item an offer allows.

Output

Print one section per product. Each section starts with the product's name on its own line, followed by $E$ lines -- one per query, in the same order as the input. Every line has the form

Buy N, save $D

where N is the requested quantity and D is the amount saved compared with taking no free items. D is written in the form

d.dd

that is, at least one digit for the dollars, a decimal point, and exactly two digits for the cents.

Separate consecutive product sections with a blank line.