You are given four diverse integer focuses p1, p2, p3 and p4 on XY matrix. In one stage you can pick one of the focuses pi and move it in one of four ways by one. All in all, if you have picked point pi=(x,y) you can move it to (x,y+1), (x,y−1), (x+1,y) or (x−1,y). Your objective to move
Correct answer will be upvoted else Multiple Downvoted. Computer science.
You are given four diverse integer focuses p1, p2, p3 and p4 on XY matrix.
In one stage you can pick one of the focuses pi and move it in one of four ways by one. All in all, if you have picked point pi=(x,y) you can move it to (x,y+1), (x,y−1), (x+1,y) or (x−1,y).
Your objective to move focuses so that they will shape a square with sides corresponding to OX and OY tomahawks (a square with side 0 is permitted).
What is the base number of steps you want to make such a downer?
Input
The principal line contains a solitary integer t (1≤t≤104) — the number of experiments.
Each experiment comprises of four lines. Each line contains two integers x and y (0≤x,y≤109) — directions of one of the focuses pi=(x,y).
All focuses are distinctive in one experiment.
Output
For each experiment, print the single integer — the base number of steps to make a square.
Step by step
Solved in 4 steps with 1 images