I |
Take Me Home (To the Place I Belong) |
|
Input: Standard Input Output: Standard Output |
|
At last, eminent scientist Safdar
Ali has decided to return to his beloved homeland
There will be several test cases. For each test case, the first line contains 3 numbers: C, M and N, where C (0≤C≤10000) represents the extra cost that will be added for each type of boxes, M (0<M<1001) represents the number of types of boxes offered by the “Pack-em-up” Company, and N(0<N<1001) represents the number of types of boxes required by Safdar Ali. After that there will be M lines, each containing two integers mi(0< mi<100000001) and pi(0< pi<10001) where mi represents the size of the boxes and pi represents the price of each box of that size. Then there will be N lines each containing 2 integer number ni (0<ni<100001) (represents the size of the objects that is required to pack) and ri ni (0<ri<1001) (which represents the number of boxes that are required of that type). Input will be terminated when C=M=N=0.
For each test case, there will be one line of output. First print the test case number (see the sample output) and then the minimum costs to pack all of the objects. If it is not possible to pack, your output should be “not possible”.
1000 4 3 5 10 7 12 9 15 11 17 1 10 2 20 10 10 100 4 3 5 10 7 12 9 15 10 17 1 10 2 20 12 10 0 0 0 |
case 1: 1680 case 2: not
possible |
PS: Syed Monowar Hossain
Special Thanks: Abdullah al Mahmood, Shahriar Manzoor