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 = '\ncost = {}\ntip = {}\n\n# cost[(1, 0, 0)] = 0\n\n# cost[(2, 0, 0)] = 1\n# cost[(2, 1, 0)] = 1\n# cost[(2, 0, 1)] = 2\n# cost[(2, 1, 1)] = 2\n# cost[(2, 0, -1)] = 2\n# cost[(2, -1, 0)] = 2\n# cost[(2, -1, -1)] = 3\n\n# cost[(3, 1, 1)] = 1\n# cost[(3, 0, 0)] = 2\n# cost[(3, 0, 1)] = 1\n# cost[(3, 1, 0)] = 1\n\n# cost[(4, 0, 0)] = 1\n# cost[(4, 1, 1)] = 2\n# cost[(4, 0, 1)] = 1\n# cost[(4, 1, 0)] = 2\n\n\nd = {\n\t1 : [(2, 1, 0), (3, 1, 0), (4, 0, 0), (3, 0, 1), (2, 0, 0), (4, 0, 1), (3, 1, 1)],\n\t2 : [(1, 0, 0), (3, 0, 1), (4, 0, 1), (1, -1, 0), (3, 0, 0), (4, -1, 0), (4, -1, 1)],\n\t3 : [(2, 0, 0), (1, -1, 0), (4, -1, 0), (4, 0, 0), (1, 0, -1), (2, 0, -1), (1, -1, -1)],\n\t4 : [(1, 0, -1), (2, 0, -1), (3, 0, 0), (1, 0, 0), (2, 1, 0), (3, 1, 0), (2, 1, -1)]\n}\n\n\ndef dfs(t, x, y, dist, cost):\n\tif dist >= 4:\n\t\treturn []\n\n\tif (t, x, y) in cost:\n\t\tcost[(t, x, y)] = min(cost[(t, x, y)], dist)\n\telse:\n\t\tcost[(t, x, y)] = dist\n\n\tfor e in d[t]:\n\t\tdfs(e[0], x + e[1], y + e[2], dist + 1, cost)\n\n\ntip[((0, 1),(1, 0))] = 1\ntip[((1, 0),(0, 1))] = 1\n\ntip[((0, -1),(1, 0))] = 4\ntip[((1, 0),(0, -1))] = 4\n\ntip[((0, 1),(-1, 0))] = 2\ntip[((-1, 0),(0, 1))] = 2\n\ntip[((0, -1),(-1, 0))] = 3\ntip[((-1, 0),(0, -1))] = 3\n\n\ndef test(a, b, c):\n\tif b[0] != c[0] and b[1] != c[1]:\n\t\treturn True\n\treturn False\n\n\ndef dd(a, b):\n\treturn (b[0] - a[0], b[1] - a[1])\n\ndef conv(coords):\n\n\ta = (coords[0], coords[1])\n\tb = (coords[2], coords[3])\n\tc = (coords[4], coords[5])\n\n\tcenter = a\n\to1 = b\n\to2 = c\n\n\tif test(b, a, c):\n\t\tcenter = b\n\t\to1 = a\n\t\to2 = c\n\n\tif test(c, a, b):\n\t\tcenter = c\n\t\to1 = a\n\t\to2 = b\n\n\ttp = tip[(dd(center, o1), dd(center, o2))]\n\t(x, y) = center\n\t# print(center, dd(center, o1), dd(center, o2))\n\treturn (tp, x, y)\n\ndef sgn(tp, dx, dy):\n\tif tp == 1 or tp == 3:\n\t\tif dx * dy <= 0:\n\t\t\treturn 0\n\t\treturn 1\n\n\tif dx * dy <= 0:\n\t\treturn 1\n\treturn 0\n\ndef get_cost(tp, x, y, xf, yf):\n\tdiag = min(abs(x - xf), abs(y - yf))\n\tlin = max(abs(x - xf), abs(y - yf))\n\n\treturn 2 * lin + sgn(tp, x - xf, y - yf) * 10\n\n\ndef solve(coords):\n\n\t(t, x, y) = conv(coords)\n\n\tto = {}\n\n\tdfs(t, x, y, 0, to)\n\n\t# print(t, x, y)\n\n\tans = 1e18\n\t\n\tfor e in cost:\n\t\tfor f in to:\n\t\t\tif f[0] == e[0]:\n\t\t\t\tans = min(ans, cost[e] + to[f] + get_cost(e[0], e[1], e[2], f[1], f[2]))\n\n\treturn ans\n\n\nlst = dfs(1, 0, 0, 0, cost)\n\n\n# print(len(cost))\n\nn = int(input())\nfor i in range(n):\n\tcoords = list(map(int, input().split()))\n\tprint((solve(coords)))\n\n\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 21301