# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

The problem title doesn't mean anything, right? WRONG! It's a fact!

Anyway, let's get to business. There are two weird persons in two countries. The weird fact about them is that the more distant they are from each other, the more their body hurts. And when they are closest, the pain is minimal. One of the countries is circular and the other one is elliptical. The elliptical country has its main axis parallel to the X-axis of the co-ordinate system.

The two persons can go anywhere in their countries, respectively. Can you find out the minimum distance between them?

The equation of an axis parallel ellipse is **(x-h) ^{2} / a^{2} + (y-k)^{2} / b^{2} = 1**, where

Also, if the two countries overlap anywhere, then the distance is **0**.

The first line contains an integer **T (1 <= T <= 10 ^{5})**, denoting the number of test cases. Each of the test cases contains

For each test case, you have to output the minimum distance between the two persons. The answer should be rounded to **4** digits after decimal.

Input | Output |
---|---|

2 0 0 1 0 0 4 2 -3 3 1 0 0 4 2 | 0.0000 0.5219 |

100% Solution Ratio

mahdi.hasnatEarliest,

neo11235Fastest, 0.4s

mahdi.hasnatLightest, 1.2 MB

omar24Shortest, 963B

Login to submit