The challenge is to keep the lever balanced while adjusting the objects on it. Assume you have a straight, evenly weighted board, 20 meters long and weighing three kilograms. The middle of the board is the center of mass, and we will call that position 0. So the possible positions on the board range from -10 (the left end) to +10 (the right end). The board is supported at positions -1.5 and +1.5 by two equal fulcrums, both two meters tall and standing on a flat floor. On the board are six packages, at positions -8, -4, -3, 2, 5 and 8, having weights of 4, 10, 10, 4, 7 and 8 kilograms, respectively as in the picture below.
You are to write a program which solves problems like the one described above. The input contains multiple cases. Each case starts with three integers: the length of the board (in meters, at least 3), the weight of the board (in kilograms) and n the number of packages on the board (n <= 20). The board is supported at positions -1.5 and +1.5 by two equal fulcrums, both two meters tall and standing on a flat floor. The following n lines contain two integers each: the position of a package on board (in meters measured from the center, negative means to the left) and the weight of the package (in kilograms). A line containing three 0's ends the input. For each case you are to output the number of the case in the format shown below and then n lines each containing 2 integers, the position of a package and its weight, in an order in which the packages can be removed without causing the board to tip. If there is no solution for a case, output a single line Impossible. There is no solution if in the initial configuration the board is not balanced.
20 3 6 -8 4 -4 10 -3 10 2 4 5 7 8 8 20 3 15 1 10 8 5 -6 8 5 9 -8 4 8 10 -3 10 -4 5 2 9 -2 2 3 3 -3 2 5 1 -6 1 2 5 30 10 2 -8 100 9 91 0 0 0Possible Output for sample input
Case 1: -4 10 8 8 -8 4 5 7 -3 10 2 4 Case 2: 1 10 8 5 -6 8 5 9 -8 4 8 10 -3 10 -4 5 2 9 -2 2 3 3 -3 2 5 1 -6 1 2 5 Case 3: Impossible