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

#define sz(x)           (int)((x).size())
#define pb              push_back
#define popb            pop_back
#define all(x)          (x).begin(),(x).end()
#define loop(i,a,n)     for(ll (i) = (a); (i) < (n); (++i))
#define rloop(i,a,n)    for(ll (i) = (a); (i) > (n); (--i))
#define mem1(a)         memset((a),-1,sizeof(a));
#define mem0(a)         memset((a),0,sizeof(a));
#define ll              long long
#define MOD             1000000007
#define fi              first
#define sec             second
/*ll Modular_Exponentiation(ll x, ll n, ll M)
{
   if (n == 0) return 1;
   if (n % 2) return (x * Modular_Exponentiation((x * x) % M, n / 2, M)) % M;
   else return (Modular_Exponentiation((x * x) % M, n / 2, M)) % M;
}
 
void sieve(ll n)
{
    for(ll i=2;i*i<=n;i++){
        if(prime[i]==0){
            prime[i]=i;
            for(ll j=i*i;j<=n;j+=i){
                prime[j]=i;
            }
        }
    }
}
 
ll gcd(int a,int b){
    if(b==0){
        return a;
    }
    return gcd(b,b%a);
}
 
 
ll countPrimeFactors(ll a) {
    ll ans = 0;
    for (ll i = 2; i * i <= a; i++) {
        while (a % i == 0) {
            ans++;
            a /= i;
        }
    }
    if (a > 1) {
        ans++;
    }
    return ans;
}
 
class ExtEuclidTriplet{
    public :
    int gcd;
    int x;
    int y;
};
 
ExtEuclidTriplet gcdExtEuclid(ll a, ll b){
    if(b == 0){
        ExtEuclidTriplet base;
        base.x = 1;
        base.y = 0;
        base.gcd = a;
        return base;
 
    }
    ExtEuclidTriplet temp = gcdExtEuclid(b, a%b);
    ExtEuclidTriplet myAns;
    myAns.gcd = temp.gcd;
    myAns.x = temp.y;
    myAns.y = (temp.x - (a/b)*temp.y);
    return myAns;
}
 
int modInverse(ll a, ll b){
    ll ans = gcdExtEuclid(a,b).x;
    return (ans%b + b)%b;
}*/

 
const int N=1e5+5; 
 
void solve(){
    int xa,ya,xb,yb,xc,yc;
    cin>>xa>>ya>>xb>>yb>>xc>>yc;
    if(xc > max(xa,xb) or xc < min(xa,xb) or yc > max(ya,yb) or yc < min(ya,yb)){
        cout<< abs(xa-xb) + abs(ya-yb) << endl;
    }
    else if(xc < max(xa,xb) and yc < max(ya,yb) and xc > min(xa,xb) and yc > min(ya,yb)){
        cout<< abs(xa-xb) + abs(ya-yb) << endl;
    }
    else{
        if((xa == xb and xc == xa) or (ya == yb and yc == ya)){
            cout<< abs(xa-xb) + abs(ya-yb) + 2 << endl;
        }
        else{
            cout<< abs(xa-xb) + abs(ya-yb) << endl;
        }

    }


}  
 
int main()
{
    std::ios_base::sync_with_stdio(false);
    
#ifndef ONLINE_JUDGE
 
freopen("input.txt", "r", stdin);
 
freopen("output.txt", "w", stdout);
 
#endif 
   ll t; cin>>t;
   while(t--){
        solve();
   }
    
}