#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pll pair<ll, ll>
#define vl vector<ll>
#define pb push_back
#define pp pop_back
#define f(i, a, b) for (ll i = a; i < b; ++i)
#define rev(i, a, b) for (ll i = a; i >= b; --i)
#define print(x) cout << x << endl
#define endl '\n'
#define F first
#define S second
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define to(n) to_string(n)
#define sort(v) sort(v.begin(), v.end())
#define low(v, n) lower_bound(v.begin(), v.end(), n) - v.begin()
#define upp(v, n) upper_bound(v.begin(), v.end(), n) - v.begin()
#define mod 1000000007
#define mex 100005

ll exp(ll x, ll y)
{
    if (y == 0)
    {
        return 1;
    }
    if (y % 2 == 0)
    {
        return exp((x % mod) * (x % mod), y / 2) % mod;
    }
    else
    {
        return ((x % mod) * exp((x % mod) * (x % mod), y / 2) % mod);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    // t=1;
    while (t--)
    {
        ll a1, a2, b1, b2, c1, c2;
        cin >> a1 >> a2;
        cin >> b1 >> b2;
        cin >> c1 >> c2;

        ll p = abs(b1 - a1) + abs(b2 - a2);

        ll q1 = max(a1, b1);
        ll q2 = max(a2, b2);

        ll r1 = min(a1, b1);
        ll r2 = min(a2, b2);

        if (c1 == r1 && c1 == q1)
        {
            if (c2 <= q2 && c2 >= r2)
            {
                p += 2;
            }
        }
        if (c2 == r2 && c2 == q2)
        {
            if (c1 <= q1 && c1 >= r1)
            {
                p += 2;
            }
        }

        print(p);
    }

    return 0;
}