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 queue import deque\n\ndef move(ku):\n\tx, y, dx, dy = ku\n\treturn (\n\t\t(x + dx, y + dy, -dx, -dy),\n\t\t(x, y, -dx, dy),\n\t\t(x, y + dy, -dx, -dy),\n\t\t(x, y + dy, dx, -dy),\n\t\t(x, y, dx, -dy),\n\t\t(x + dx, y, -dx, dy),\n\t\t(x + dx, y, -dx, -dy),\n\t)\n\ndef calc(x, y, dx, dy):\n\tif dx == 1 and dy == 1:\n\t\tif x == 0 and y == 0:\n\t\t\treturn 0\n\t\telif x == y:\n\t\t\treturn abs(x) * 2 + 1\n\t\telse:\n\t\t\treturn max(abs(x), abs(y)) * 2\n\telif dx == -1 and dy == 1:\n\t\tif x == 0 and y == 0:\n\t\t\treturn 1\n\t\telif abs(x) - abs(y) == 0:\n\t\t\tif x < 0:\n\t\t\t\treturn abs(x) * 2 + 1\n\t\t\telse:\n\t\t\t\treturn abs(y) * 2\n\t\telif abs(x) - abs(y) < 0:\n\t\t\treturn abs(y) * 2\n\t\telse:\n\t\t\tif x < 0:\n\t\t\t\treturn abs(x) * 2 + 1\n\t\t\telse:\n\t\t\t\treturn abs(x) * 2 - 1\n\telif dx == 1 and dy == -1:\n\t\tif y <= 0:\n\t\t\tif abs(x) - abs(y) <= 0:\n\t\t\t\treturn abs(y) * 2 + 1\n\t\t\telse:\n\t\t\t\treturn abs(x) * 2\n\t\telse:\n\t\t\tif abs(x) - abs(y) < 0:\n\t\t\t\treturn abs(y) * 2 - 1\n\t\t\telse:\n\t\t\t\treturn abs(x) * 2\n\telse:\n\t\tif x == 0 and y == 0:\n\t\t\treturn 2\n\t\telif x == 1 and y == 1:\n\t\t\treturn 1\n\t\telif y < 0:\n\t\t\tif x < 0:\n\t\t\t\tif abs(x) - abs(y) == 0:\n\t\t\t\t\treturn abs(x) * 2 + 2\n\t\t\t\telif abs(x) - abs(y) < 0:\n\t\t\t\t\treturn abs(y) * 2 + 1\n\t\t\t\telse:\n\t\t\t\t\treturn abs(x) * 2 + 1\n\t\t\telse:\n\t\t\t\tif abs(x) - abs(y) == 0:\n\t\t\t\t\treturn abs(x) * 2 + 1\n\t\t\t\telif abs(x) - abs(y) < 0:\n\t\t\t\t\treturn abs(y) * 2 + 1\n\t\t\t\telse:\n\t\t\t\t\treturn abs(x) * 2 - 1\n\t\telse:\n\t\t\tif x < 0:\n\t\t\t\tif abs(x) - abs(y) < -1:\n\t\t\t\t\treturn abs(y) * 2 - 1\n\t\t\t\telse:\n\t\t\t\t\treturn abs(x) * 2 + 1\n\t\t\telse:\n\t\t\t\tif abs(x) - abs(y) == 0:\n\t\t\t\t\treturn abs(x) * 2\n\t\t\t\telif abs(x) - abs(y) < 0:\n\t\t\t\t\treturn abs(y) * 2 - 1\n\t\t\t\telse:\n\t\t\t\t\treturn abs(x) * 2 - 1\n\nT = int(input())\n\nfor _ in range(T):\n\tax, ay, bx, by, cx, cy = list(map(int, input().split()))\n\t\n\tif ax == bx:\n\t\tgx = ax\n\telif bx == cx:\n\t\tgx = bx\n\telse:\n\t\tgx = cx\n\t\n\tif ay == by:\n\t\tgy = ay\n\telif by == cy:\n\t\tgy = by\n\telse:\n\t\tgy = cy\n\t\n\txs = [ax, bx, cx]\n\txs.remove(gx)\n\txs.remove(gx)\n\t\n\tys = [ay, by, cy]\n\tys.remove(gy)\n\tys.remove(gy)\n\t\n\tdx = xs[0] - gx\n\tdy = ys[0] - gy\n\t\n#\tgoal = (gx, gy, dx, dy)\n\t\n\tprint((calc(gx, gy, dx, dy)))\n\t\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 286617