Problem G
E-coins
Input:standard input
Output:standard output
Time Limit:10 seconds
Memory limit:32 MB
At the Department for Bills and coins, a extension of today ' s monetary system has newly been T fit the new economy better. A number of new so called E-coins would be produced, which, in addition to have a value in the normal sense of today, ALS o have an infotechnological value. The goal of this reform are, of course, to make justice to-economy of numerous dotcom, companies which, despite the fact That's they are low on money surely have a lot of IT inside. All money of the old kind would keep its conventional value and get zero infotechnological value.
To successfully make value comparisons in the new system, something called the E-modulus is introduced. This is calculated as SQRT (x*x+y*y) where X and Y hold the sums of the Conventional and infotechnological values respectively. For instance, conventional value of $ altogether and an infotechnological value of $ 'll get a e-modulus of $ . Bear in mind it you have to calculate the sums of the conventional and infotechnological values separately your CA Lculate the E-modulus of the money.
To simplify the "move" to E-currency, your are assigned to write a, which given the e-modulus that shall is reached an D A list of the different types of e-coins that are available and calculates the smallest amount of e-coins that are needed t O exactly match the e-modulus. There is no limit in how many e-coins of each type of this is used to match the given E-modulus.
Input
Line A and the number of problems N (0<n<=100), followed by n Times:
A line with the integers m (0<m<=40) and S (0<s<=300), where m indicates the number of different e-coin types that exist in the problem, and S states the value of the e-modulus that shall to be mat Ched exactly.
m lines, each consisting of one pair of non-negative integers describing the value of a e-coin. The number in the pair states the conventional value, and the second number holds the infotechnological value of the Coin.
When more than one of the present on a line, they would be separated by a. Between each problem, there is one blank line.
Output
The output consists of n lines. Each line contains either a single integer holding the number of coins necessary to reach the specified E-modulus s 3> or, if S cannot is reached, the string "not possible".
Sample Input:
3
2 5
0 2
2 0
3 20
0 2
2 0
2 1
3 5
3 0
0 4
5 5
Sample Output:
Not possible
Ten
2