We have three stones at points (0, 0), (1,0), and (0,1) on a two-dimensional plane.
These three stones are said to form an L when they satisfy the following conditions:
 - Each of the stones is at integer coordinates.
 - Each of the stones is adjacent to another stone. (That is, for each stone, there is another stone whose distance from that stone is 1.)
 - The three stones do not lie on the same line.
Particularly, the initial arrangement of the stone - (0, 0), (1,0), and (0,1) - forms an L.
You can do the following operation any number of times: choose one of the stones and move it to any position. However, after each operation, the stones must form an L.
You want to do as few operations as possible to put stones at points (ax, ay), (bx, by), and (cx, cy). How many operations do you need to do this?
It is guaranteed that the desired arrangement of stones - (ax, ay), (bx, by), and (cx, cy) - forms an L. Under this condition, it is always possible to achieve the objective with a finite number of operations.
You will be given T cases of this problem. Solve each of them.

-----Notes-----
We assume that the three stones are indistinguishable. For example, the stone that is initially at point (0,0) may be at any of the points (ax, ay), (bx, by), and (cx, cy) in the end.

-----Constraints-----
 - 1 \leq T \leq 10^3
 - |ax|,|ay|,|bx|,|by|,|cx|,|cy| \leq 10^9
 - The desired arrangement of stones - (ax, ay), (bx, by), and (cx, cy) - forms an L.

-----Input-----
Input is given from Standard Input in the following format:
T
\text{case}_1
\vdots
\text{case}_T

Each case is in the following format:
ax ay bx by cx cy

-----Output-----
Print T values. The i-th value should be the minimum number of operations for \text{case}_i.

-----Sample Input-----
1
3 2 2 2 2 1

-----Sample Output-----
4

Let us use # to represent a stone.
You can move the stones to the specified positions with four operations, as follows:
....    ....    ....    ..#.    ..##
#... -> ##.. -> .##. -> .##. -> ..#.
##..    .#..    .#..    ....    ....

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+"\\n")\n\n_turnx = {\n    1: 4,\n    2: 3,\n    3: 2,\n    4: 1\n}\n_turn90 = {\n    1: 4,\n    2: 3,\n    3: 1,\n    4: 2\n}\ndef subx(a,b,d):\n    if isinstance(a, tuple):\n        return min(subx(item,b,d) for item in a)\n    if d<0:\n        return subx(_turnx[a], _turnx[b], -d)\n    return suby(_turn90[a], _turn90[b], d)\n_turny = {\n    1: 3,\n    2: 4,\n    3: 1,\n    4: 2,\n}\ndef suby(a,b,d):\n    if isinstance(a, tuple):\n        return min(suby(item,b,d) for item in a)\n    if d<0:\n        return suby(_turny[a], _turny[b], -d)\n    elif d==0:\n        if a==b:\n            return 0\n        else:\n            return 1\n    elif d==1:\n        if a in (2,3) and b in (1,4):\n            return 1\n        elif a in (1,4) and b in (2,3):\n            return 3\n        else:\n            return 2\n    else:\n        ans = 2*(d-2)\n        if a in (1,4):\n            ans += 3\n        else:\n            ans += 2\n        if b in (1,4):\n            ans += 1\n        else:\n            ans += 2\n    return ans\nans = float("inf")\nt = int(input())\nfor ind in range(t):\n    ax,ay,bx,by,cx,cy = list(map(int, input().split()))\n    if ax!=bx:\n        if bx==cx:\n            ax,ay,cx,cy = cx,cy,ax,ay\n        else:\n            bx,by,cx,cy = cx,cy,bx,by\n    if cx>ax:\n        if cy==max(ay,by):\n            k = 3\n        else:\n            k = 1\n    else:\n        if cy==max(ay,by):\n            k = 2\n        else:\n            k = 4\n    tx,ty = min(ax,bx,cx), min(ay,by,cy)\n    if tx==0:\n        if ty==0:\n            ans = suby(1,k,0)\n        else:\n            ans = suby(1,k,ty)\n    elif ty==0:\n        ans = subx(1,k,tx)\n    else:\n        if tx>0 and ty>0:\n            ans = 2*min(tx,ty) + 1\n            if tx>ty:\n                ans += subx((1,3,4),k,tx-ty)\n            elif ty>tx:\n                ans += suby((1,3,4),k,ty-tx)\n            else:\n                ans += suby((1,3,4),k,0)\n        elif tx>0 and ty<0:\n            tx,ty = abs(tx), abs(ty)\n            ans = 2*min(tx,ty)\n            if tx>ty:\n                ans += subx((1,3),k,tx-ty)\n            elif ty>tx:\n                ans += suby((1,3),k,tx-ty)\n            else:\n                ans += suby((1,3),k,0)\n        elif tx<0 and ty>0:\n            tx,ty = abs(tx), abs(ty)\n            ans = 2*min(tx,ty)\n            if tx>ty:\n                ans += subx((1,4),k,-tx+ty)\n            elif ty>tx:\n                ans += suby((1,4),k,-tx+ty)\n            else:\n                ans += suby((1,4),k,0)\n        else:\n            tx, ty = abs(tx), abs(ty)\n            ans = 2*min(tx,ty)\n            if tx>ty:\n                ans += subx((2,3,4),k,ty-tx)\n            elif ty>tx:\n                ans += suby((2,3,4),k,tx-ty)\n            else:\n                ans += suby((2,3,4),k,0)\n    print(ans)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 15959