Fear of The Dark

“At night or strolling through the park, fear of the dark.” When Dickenson was walking in a dark road, he noticed that he has been surrounded by N ghosts. So he stopped at the point (x, y) and realized that each ghost is shaped like a line segment. The ghosts are fixed at their positions and they are not moving. Dickenson was lucky that he was carrying a gun which can shoot “anti-ghost” ray to kill ghosts. But the gun can shoot the ray at a particular angle θ and can shoot at most K shots. The angle θ cant be less than 1 degree or greater than 180 degree. Whenever he shoots a ray, the ray spreads at the angle θ and goes towards infinity and destroying any body parts of the ghosts in its path. A ghost is said to be killed if “anti-ghost” rays destroy its whole body. If there is just a single point on the ghosts body that is not being destroyed, the ghost is alive. He can shoot to any direction. Note that sometimes he may need several shots at several directions to completely kill a ghost. Given Dickensons position (x, y), the maximum shots K and the endpoints of the body of all the ghosts you have to determine the minimum angle which can be used to kill all the ghosts. The above picture shows how the gun works. A shot has been made at the angle ‘θ’ and the ray destroyed some parts of the ghost G1 and then it destroyed the whole body of the ghost G2. Input The first line of the input contains X, the number of test cases. Each case starts with four numbers N (1 ≤ N ≤ 50), K (1 ≤ K ≤ 10), x and y. Where N is the number of ghosts, K is the maximum number of shots that can be made using the gun, (x,y) is the Cartesian co-ordinate of Dickenson’s position. Then there will be N lines containing four numbers x1, y1, x2 and y2 describing each ghosts body. Here (x1,y1) and (x2,y2) are the end points of a ghosts body. All the co-ordinates in the input file have an absolute magnitude at most 10,000. For no ghost (x1, y1), (x2, y2) and (x, y) will be collinear. Output For every test case you have to output one line which contains the minimum angle θ to shoot all the ghosts. You have to output θ to 4 decimal places. Errors less than or equal to ±0.0001 are considered to be correct. If it is impossible to kill all the ghosts then output ‘-1.0000’.

2/2 Sample Input 1 4300 2 2 2 -2 3331 4282 -6 1 -6 0 Sample Output 45.0000