A dam has n water gates to let out water when necessary. Each water gate has its own capacity, water path and affected areas in the downstream. The affected areas may have a risk of flood when the water gate is open. The cost of potential damage caused by a water gate is measured in number calculated from the number of people and areas estimated to get affected.
Suppose a water gate G_i has the volumetric flow rate of F_i m^3/hour and the damage cost of C_i. In a certain situation, the dam has the volume V m^{3 }of water to flush out within T hours. Your task is to manage the opening of the water gates in order to get rid of at least the specified volume of water within a limited time in condition that the damage cost is minimized.
For example, a dam has 4 water gates and their properties are shown in the following table.
Case 1: You have to flush out the water 5 million m^{3 }within 7 hours. The minimum cost will be 120,000 by letting the water gate G_1 open for 7 hours.
Case 2: You have to flush out the water 5 million m^{3 }within 30 hours. The minimum cost will be 110,000 by letting the water gates G_2 and G_3 open, for example, G_2 is open for 29 hours and G_3 is open for 28 hours.
Note that each water gate is independent and it can be open only in a unit of whole hour (no fraction of hour).
The first line includes an integer n indicating number of water gates (1 ≤ n ≤ 20). Then the next n lines contain, in each line, two integers: F_i and C_i corresponding to the flow rate (m^3/hour) and the damage cost of the water gate G_{i }_{ }respectively. The next line contains the number m which is the number of test cases (1 ≤ m ≤ 50). The following m lines contain, in each line, two integers: V and T corresponding to the volume (m^3) of water to let out within T hours.
1 ≤ F_i, V, C_i ≤ 10^9, 1 ≤ T ≤ 1000
For each test case, print out the minimum cost in the exact format shown in the sample output below. If it is not possible to let out the water of volume V in T hours from the dam, print out "IMPOSSIBLE" (without quotation marks).