
The streets of Manhattan form a grid. When the grid lines are parallel to the x- and y-axes, the distance you must walk or drive from one point to another — moving only along the streets, never cutting through buildings — equals $\Delta x + \Delta y$. This is the Manhattan distance.
Now suppose the land outside the city grid is completely flat, with no obstacles, so you may move freely in any direction there. We want to travel from point $A$ to point $B$, where each point may lie inside the grid, on it, or outside it. Outside the city the shortest route is not necessarily the Manhattan distance: if both points lie on the grid it is the Manhattan distance, but if, for example, both lie north of the grid, the shortest route is the straight-line (Euclidean) distance. Other configurations can be more involved.
Two opposite corners of the city grid are given. The grid lines are parallel to the coordinate axes, and consecutive grid lines (horizontal or vertical) are $1$ unit apart. Two points $A$ and $B$ with integer coordinates are also given. Compute the length of the shortest path from $A$ to $B$, given that inside the city grid you may move only along the grid lines (the streets).
The input consists of several datasets. Each dataset is a single line with eight integers:
$$x_L \quad y_L \quad x_U \quad y_U \quad x_A \quad y_A \quad x_B \quad y_B$$
Here $L = (x_L, y_L)$ and $U = (x_U, y_U)$ are the lower-left and upper-right corners of the city grid, and $A = (x_A, y_A)$ and $B = (x_B, y_B)$ are the two points to travel between.
Every integer is in the range $-1000$ to $1000$ inclusive, with $x_L < x_U$ and $y_L < y_U$. The input ends with a line containing eight zeros, which is not processed.
For each dataset, print one line containing the length of the shortest path from $A$ to $B$, rounded to exactly three decimal places.