Hector & Safe house
Tag(s):

## Easy, Easy-Medium

Problem
Editorial
Analytics

DEA is currently struggling with a case of cooking Blue Crystal in Albuquerque. Hector Salamanca is a key witness of this case as he knows a lot of stuff regarding the Gang responsible for cooking & distribution of Blue Crystal.

"Hector Salamanca..? That Name rings a Bell!"

He agreed to tell everything he knows about this case to DEA. Gus Fring & Heisenberg are two people of the Gang which cook the Blue Crystal & they came to know about this. So, both of them want Hector to be dead before he tells anything to the DEA & Hank Schrader.

Heisenberg lives at a point (x1,y1) & Gus Fring at (x2,y2), both in Albuquerque.

Suddenly, DEA came to know that some of the Gang members want to kill Hector.

So, DEA is looking for a safe house along ax+by+c=0 (the border of Albuquerque), where they can ask Hector about the information he knew.

DEA also knows about the coordinates of Heisenberg & Gus & they want the safe house to be at a location which maximizes the difference between distance of the safe house to Heisenberg's House & distance of the safe house to Gus Fring's House.

Help DEA in finding the maximum absolute difference between the distance between safe house & Heisenberg’s house and distance between safe house & Gus Fring’s house i.e.

• Maximum value of absolute((distance between safe house & Heisenberg’s house) - (distance between safe house & Gus Fring’s house)).

INPUT:

First line contains an integer T denoting the number of test case(s).

Each test case consists of two lines.

First line of each test case contains three integers a, b & c, describing the equation of the border of Albuquerque along which DEA is looking for a safe house.

Second line of each test case contains four integers x1, y1, x2, y2.

OUTPUT:

For each test case output the integral part of answer in separate line.

CONSTRAINTS

• 1 ≤ T ≤ 106
• -103 ≤ a,b,c ,x1,y1,x2,y2 ≤ 103

NOTE : Answer to the given problem always exists.

SAMPLE INPUT
1
-5 3 1
-1 4 -8 -5
SAMPLE OUTPUT
11
Explanation

Equation of the line L (on which there is Safe House) is
-5x+3y+1=0
Co-ordinates of the houses of Heisenberg & Gus are-
(x1,y1) ≡ (-1,4)
(x2,y2) ≡ (-8,-5)

Max. difference between the (Safe House - Heisenberg House length) & (Safe House - Gus Fring's House length) is approx. 11.401.
So the integral part (floor value) is 11.

Time Limit: 3.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Scala 2.11.8, Swift, Visual Basic

## CODE EDITOR

Initializing Code Editor...