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 = 'from collections import deque\n\ndef di(x,y,z,w):\n    return abs(x-z) + abs(y-w)\n\ndef convert(a,b,c,d,e,f):\n    if di(c,d,a,b)==1 and di(c,d,e,f)==1:\n        a,b,c,d = c,d,a,b\n    elif di(e,f,c,d)==1 and di(e,f,a,b)==1:\n        a,b,e,f = e,f,a,b\n    if c==a:\n        if d==b+1:\n            if e==a+1:\n                a,b,c,d,e,f = a,b,a+1,b,a,b+1\n            else:\n                a,b,c,d,e,f = a,b,a,b+1,a-1,b\n        else:\n            if e==a+1:\n                a,b,c,d,e,f = a,b,a+1,b,a,b-1\n            else:\n                a,b,c,d,e,f = a,b,a-1,b,a,b-1\n    elif c==a+1:\n        if f==b+1:\n            a,b,c,d,e,f = a,b,a+1,b,a,b+1\n        else:\n            a,b,c,d,e,f = a,b,a+1,b,a,b-1\n    else:\n        if f==b+1:\n            a,b,c,d,e,f = a,b,a,b+1,a-1,b\n        else:\n            a,b,c,d,e,f = a,b,a-1,b,a,b-1\n    return (a,b,c,d,e,f)\n\ndist = {}\npos = (0,0,1,0,0,1)\ndeq = deque([pos])\ndist[pos] = 0\nwhile deq:\n    a,b,c,d,e,f = deq.popleft()\n    D = dist[a,b,c,d,e,f]\n    if D==10:\n        continue\n\n    nx,ny = 1,1\n\n    if (c,d)==(a+1,b) and (e,f)==(a+1,b):\n        nx,ny = 1,1\n    elif (c,d)==(a,b+1) and (e,f)==(a-1,b):\n        nx,ny = -1,1\n        c,d,e,f = e,f,c,d\n    elif (c,d)==(a-1,b) and (e,f)==(a,b-1):\n        nx,ny =-1,-1\n    elif (c,d)==(a+1,b) and (e,f)==(a,b-1):\n        nx,ny = 1,-1\n\n    if convert(a+nx,b+ny,e,f,c,d) not in dist:\n        dist[convert(a+nx,b+ny,e,f,c,d)] = D + 1\n        deq.append(convert(a+nx,b+ny,e,f,c,d))\n\n    if convert(e,f,e-nx,f,a,b) not in dist:\n        dist[convert(e,f,e-nx,f,a,b)] = D + 1\n        deq.append(convert(e,f,e-nx,f,a,b))\n    if convert(a,b,e,f,a-nx,b) not in dist:\n        dist[convert(a,b,e,f,a-nx,b)] = D + 1\n        deq.append(convert(a,b,e,f,a-nx,b))\n    if convert(e,f,e+nx,f,a,b) not in dist:\n        dist[convert(e,f,e+nx,f,a,b)] = D + 1\n        deq.append(convert(e,f,e+nx,f,a,b))\n\n    if convert(c,d,a,b,c,d-ny) not in dist:\n        dist[convert(c,d,a,b,c,d-ny)] = D + 1\n        deq.append(convert(c,d,a,b,c,d-ny))\n    if convert(a,b,c,d,a,b-ny) not in dist:\n        dist[convert(a,b,c,d,a,b-ny)] = D + 1\n        deq.append(convert(a,b,c,d,a,b-ny))\n    if convert(c,d,c,d+ny,a,b) not in dist:\n        dist[convert(c,d,c,d+ny,a,b)] = D + 1\n        deq.append(convert(c,d,c,d+ny,a,b))\n\n#print(dist)\n#return\n\nimport sys\n\ninput = sys.stdin.readline\n\nans = []\nfor _ in range(int(input())):\n    a,b,c,d,e,f = map(int,input().split())\n    if di(c,d,a,b)==1 and di(c,d,e,f)==1:\n        a,b,c,d = c,d,a,b\n    elif di(e,f,c,d)==1 and di(e,f,a,b)==1:\n        a,b,e,f = e,f,a,b\n    if c==a:\n        if d==b+1:\n            if e==a+1:\n                a,b,c,d,e,f = a,b,a+1,b,a,b+1\n            else:\n                a,b,c,d,e,f = a,b,a,b+1,a-1,b\n        else:\n            if e==a+1:\n                a,b,c,d,e,f = a,b,a+1,b,a,b-1\n            else:\n                a,b,c,d,e,f = a,b,a-1,b,a,b-1\n    elif c==a+1:\n        if f==b+1:\n            a,b,c,d,e,f = a,b,a+1,b,a,b+1\n        else:\n            a,b,c,d,e,f = a,b,a+1,b,a,b-1\n    else:\n        if f==b+1:\n            a,b,c,d,e,f = a,b,a,b+1,a-1,b\n        else:\n            a,b,c,d,e,f = a,b,a-1,b,a,b-1\n\n    res = 10**18\n\n    if (c,d,e,f)==(a+1,b,a,b+1):\n        if a*b>=0 and a and a==b:\n            res = 2 * max(abs(a),abs(b)) + 1\n        else:\n            res = 2 * max(abs(a),abs(b))\n    elif (c,d,e,f)==(a,b+1,a-1,b):\n        if a>=0 and b>=0:\n            if (a,b)==(0,0):\n                res = 1\n            elif b>=a:\n                res = 2 * b\n            else:\n                res = 2 * a - 1\n        elif a>=0 and b<0:\n            if -b>=a:\n                res = 2 * -b\n            else:\n                res = 2 * a - 1\n        elif a<0 and b>=0:\n            if b>-a:\n                res = 2 * b\n            else:\n                res = 2 * (-a) + 1\n        else:\n            if -b > -a:\n                res = 2 * -b\n            else:\n                res = 2 * (-a) + 1\n    elif (c,d,e,f)==(a+1,b,a,b-1):\n        if a>=0 and b>=0:\n            if (a,b)==(0,0):\n                res = 1\n            elif a>=b:\n                res = 2 * a\n            else:\n                res = 2 * b - 1\n        elif a>=0 and b<0:\n            if a>-b:\n                res = 2 * a\n            else:\n                res = 2 * (-b) + 1\n        elif a<0 and b>=0:\n            if -a>=b:\n                res = 2 * (-a)\n            else:\n                res = 2 * b - 1\n        else:\n            if -a>-b:\n                res = 2 * (-a)\n            else:\n                res = 2 * (-b) + 1\n    else:\n        if a>=0 and b>=0:\n            if (a,b)==(0,0):\n                res = 2\n            elif b>a:\n                res = 2 * b - 1\n            elif a>b:\n                res = 2 * a - 1\n            else:\n                if a==1:\n                    res = 1\n                else:\n                    res = 2 * a\n        elif a>=0 and b<0:\n            if -b>=a:\n                res = 2 * (-b) + 1\n            else:\n                res = 2 * a - 1\n        elif a<0 and b>=0:\n            if -a>=b:\n                res = 2 * (-a) + 1\n            else:\n                res = 2 * b - 1\n        else:\n            if a!=b:\n                res = 2 * max(-a,-b) + 1\n            else:\n                res = 2 + 2 * abs(a)\n    ans.append(res)\n\nprint(*ans,sep="\\n")\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 84621