Hank's Master Plan

0

0 votes
Geometry, Easy-Medium, Math, Easy-Medium
Problem

One day Heisenberg and Jesse were cooking meth in Jesse's house which was located in the city of Albuquerque. Suddenly, Skinny Pete and Badger along with a lot of other guys came to party in Pinkman's House. Heisenberg, being a strict guy gets angry and gets out of the house. He gets into the RV and drives to a stranded place somewhere in Albuquerque.

enter image description here

As we all know, Hank Schrader being a clever DEA agent was secretly keeping his eyes on Jesse's house. He watches all these activities from outside. Now he wants to arrest both Jesse and Heisenberg as soon as possible. He gets the location of Heisenberg's RV in the form of coordinates (x1,y1) through a GPS that he secretly put inside before Heisenberg left. He also has the coordinates of Jesse Pinkman's House (x2,y2).

Seeing this, Hank now wants to kill both Jesse and Heisenberg. For that He makes a Plan. According to his plan, Hank will first arrest Jesse and then throw him in the main river, and then shoot Heisenberg. The river is in the form of a line (ax+by+c=0). He wants you to tell him the minimum distance he needs to cover to travel from Jesse's house to river & then from river to Heisenberg's Location.

NOTE :- River is the border of Albuquerque.

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 river.

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 <= 10^6

-10^3 <= a,b,c ,x1,y1,x2,y2 <= 10^3

Time Limit: 3
Memory Limit: 256
Source Limit:
Editor Image

?