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 = 'def form(ax,ay,bx,by,cx,cy):\n    # (向き, 中心のx座標, 中心のy座標) のtupleを作る\n    P=[(ax,ay),(bx,by),(cx,cy)]\n    Q=[(0,0)]\n    for i in range(3):\n        x0,y0=P[i][0],P[i][1]\n        x1,y1=P[(i-1)%3][0],P[(i-1)%3][1]\n        x2,y2=P[(i+1)%3][0],P[(i+1)%3][1]\n        if abs(x0-x1)+abs(y0-y1)==1 and abs(x0-x2)+abs(y0-y2)==1:\n            Q.append(((x1-x0),(y1-y0)))\n            Q.append(((x2-x0),(y2-y0)))\n            break\n    else: return -1\n    Q.sort()\n    if Q==[(0, 0), (0, 1), (1, 0)]: return 11, x0,y0\n    elif Q==[(-1, 0), (0, -1), (0, 0)]: return 00, x0,y0\n    elif Q==[(0, -1), (0, 0), (1, 0)]: return 10, x0,y0\n    elif Q==[(-1, 0), (0, 0), (0, 1)]: return 1, x0,y0\n\ndef move(f,x,y):\n    # 遷移可能場所を返す\n    if f==11:\n        return [(00,x+1,y+1), (10,x,y),(1,x,y),(10,x,y+1),(00,x,y+1),(1,x+1,y),(00,x+1,y)]\n    elif f==00:\n        return [(11,x-1,y-1), (1,x,y),(10,x,y),(1,x,y-1),(11,x,y-1),(10,x-1,y),(11,x-1,y)]\n    elif f==10:\n        return [(1,x+1,y-1), (11,x,y),(00,x,y),(11,x,y-1),(1,x,y-1),(00,x+1,y),(1,x+1,y)]\n    elif f==1:\n        return [(10,x-1,y+1), (00,x,y),(11,x,y),(00,x,y+1),(10,x,y+1),(11,x-1,y),(10,x-1,y)]\n\ndef same_angle(f0,x0,y0,f1,x1,y1):\n    if x1>=x0 and y1>=y0 and (f0==f1==11 or f0==f1==00): return 1\n    if x1<x0 and y1>=y0 and (f0==f1==1 or f0==f1==10): return 1\n    if x1>=x0 and y1<y0 and (f0==f1==1 or f0==f1==10): return 1\n    if x1<x0 and y1<y0 and (f0==f1==11 or f0==f1==00): return 1\n    return 0\n\ndef next_set(f,x,y):\n    # 3回の移動で移動できる場所を全列挙\n    P=[(f,x,y)]\n    res=[(f,x,y,0)]\n    for t in range(2):\n        Q=[]\n        for f,x,y in P:\n            Q.extend(move(f,x,y))\n        P=Q\n        for f,x,y in P:\n            res.append((f,x,y,t+1))\n    return res\n\ndef main():\n    ax,ay,bx,by,cx,cy=list(map(int,input().split()))\n    res=float("inf")\n    f,x,y=form(ax,ay,bx,by,cx,cy)\n    for f0,x0,y0,time0 in next_set(11,0,0):\n        for f1,x1,y1,time1 in next_set(f,x,y):\n            if same_angle(f0,x0,y0,f1,x1,y1) and max(abs(x0-x1),abs(y0-y1))>0: continue\n            if f0==f1:\n                tmp=max(abs(x0-x1),abs(y0-y1))*2+(time0+time1)\n                if res>tmp:\n                    res=tmp\n                    # print(f0,x0,y0,time0,f1,x1,y1,time1)\n    print(res)\n\n\nT=int(input())\nfor _ in range(T):\n    main()\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 22389