407667: GYM102868 E Orange

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Orangetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Orange is currently in the Cafeteria, and wants to set the world record for completing the "Trash" task. Unfortunately for Orange, the devious imposters have replaced the trivial click-and-drag interface with a complex two-dimensional grid of lattice points that Orange must travel through to get the trash lever to activate. A single move consists of Orange moving the trash lever (originally placed on a starting lattice point) to one of the four lattice points exactly 1 unit away from the current position and continuing to move until reaching the ending lattice point. Orange is known for his jittery fingers, and he absolutely cannot tolerate moving in the same direction twice in a row (e.g. he cannot move from $$$(0, 1)$$$ to $$$(0, 2)$$$ and then from $$$(0, 2)$$$ to $$$(0, 3)$$$). Overanxious Orange now wonders how long it will take him to complete his task, since his run would by default be a world record for this brand new task variant. You need to tell him the number of moves he needs to make from start to finish while keeping in mind his odd tendencies.

Input

The first line of input contains a single integer $$$C$$$ ($$$1 \leq C \leq 1000$$$) representing the number of scenarios you must consider with Orange. Each of then next $$$C$$$ lines will represent a task scenario using four space-separated integers $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$ ($$$0 \leq a, b, c, d \leq 10^{18}$$$). Orange needs to move the trash lever from lattice point $$$(a, b)$$$ to lattice point $$$(c, d)$$$.

Output

Output $$$C$$$ lines, each with a single integer representing the number of moves required in the corresponding scenario.

ExampleInput
2
1 1 3 3
0 1 1 1
Output
4
1
Note

A possible path in the first scenario is $$$(1, 1)$$$ to $$$(1, 2)$$$ to $$$(2, 2)$$$ to $$$(2, 3)$$$ to $$$(3, 3)$$$.

加入题单

上一题 下一题 算法标签: