#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(v) (v).begin(), (v).end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ll mod = 1e9 + 7;

bool isPrime(ll n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result

    x = x % p; // Update x if it is more than or
               // equal to p

    if (x == 0)
        return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll mI(ll x)
{
    return power(x,mod-2,mod);
}
ll gcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll gcd_c = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return gcd_c;
}

void solve()
{
    ll xa,xb,ya,yb,fa,fb,i,j,ans;
    cin>>xa>>ya;
    cin>>xb>>yb;
    cin>>fa>>fb;
    if(xa != xb && ya != yb)
    {
        ans = abs(xa-xb) + abs(ya-yb);
    }
    else if(xa == xb)
    {
        if(fa == xa && fb >= min(ya,yb) && fb <= max(ya,yb))
            ans = abs(ya-yb) + 2;
        else ans = abs(xa-xb) + abs(ya-yb);
    }
    else if(ya == yb)
    {
       if(fb == ya && fa >= min(xa,xb) && fa <= max(xa,xb))
            ans = abs(xa-xb) + 2;
        else ans = abs(xa-xb) + abs(ya-yb);
    }
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}