#include <iostream>
#include <bits/stdc++.h>
#include <chrono>

using namespace std;
using namespace std::chrono;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define forn(i,a,n,b) for(ll i=a;i<n;i+=b)
#define forr(i,a,n,b) for(ll i=a;i>=n;i-=b)
#define MOD 1000000007

#define vll vector<ll>
#define vb vector<bool>
#define vpll vector<pair<ll, ll>>
#define vvll vector<vector<ll>>
#define vvvll vector<vector<vector<ll>>>
#define vc vector<char>
#define pll pair<ll, ll>
#define vd vector<double>

#define mem(arr, value) memset(arr, value, sizeof(arr))
#define mp(val1, val2) make_pair(val1, val2)
#define endn "\n"
#define ff first
#define ss second


// DEBUG
void __print(int x) { cerr << x; }
void __print(ll x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; }
template<typename T>
void __print(const T& x) { int _ = 0; cerr << '{'; for (auto& i : x) cerr << (_++ ? "," : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


vll fact(100001);


ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll fastexpo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(ll a, ll b, vll &v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;}

ll modulo_inv(ll a, ll b) {vll arr(3); extendgcd(a, b, arr); return arr[0];} //for non prime b
ll modulo_inv_prime(ll a, ll b) {return fastexpo(a, b - 2, b);}


ll ncr(ll n, ll r)
{
    if (n < r)
    {
        return 0;
    }
    ll ans = fact[n];
    ans = ( ans * modulo_inv_prime(fact[r], MOD) ) % MOD;
    ans = ( ans * modulo_inv_prime(fact[n-r], MOD)%MOD) % MOD;
    return ans;
}


bool compare(ll a, ll b)
{
    return a>b;
}

struct pqcomp
{
    bool operator()(ll p1, ll p2)
    {
        // max heap
        return p1 < p2;
    }
};

void solve()
{
    ll xa, ya, xb, yb, xf, yf;
    cin >> xa >> ya >> xb >> yb >> xf >> yf;
    ll d1 = abs(xa - xb) + abs(ya - yb);
    ll d2 = abs(xa-xf) + abs(ya - yf);
    ll d3 = abs(xf - xb) + abs(yf - yb);
    if( xa == xf && xf == xb )
    {
        if( (ya < yf && yf < yb) || (yb < yf && yf < ya))
            cout << d1+2<<"\n";
        else
            cout << d1 << "\n";
    }
    else if(ya == yf && yf == yb)
    {
        if( (xa < xf && xf < xb) || (xb < xf && xf < xa))
            cout << d1+2<<"\n";
        else
            cout << d1 << "\n";
    }
    else
        cout << d1 << "\n";

}


int main()
{
    fastio;
    ll t = 1;
    cin >> t;
    while(t-->0)
    {
        solve();
    }
    return 0;
}
