#include <bits/stdc++.h>

#define ll        long long 
#define T(x)      std::cin>>x;while(x--)
#define W(x)      while(x)
#define fo(i,n)   for(i = 0;i < n;++i)
#define Fo(i,n,m) for(i = (n);i < (m); ++i)
#define Fod(i,n,m)for(i = (n);i >= (m); i--)
#define pb        emplace_back
#define f         first
#define s         second
#define zr        resize
#define trav(a, b)for(auto a : b)
#define all(a)    (a).begin(), (a).end()
#define fast      std::ios_base::sync_with_stdio(false); std :: cin.tie(0);
const int N = 1e5;
const int mod = 1e9+7;
#define tooL 1000000000000000000
using namespace std;
typedef pair<ll,ll> arr;

template <typename... T>static inline void gt(T&... args){((cin >> args),...);}
template <typename... T>static inline void wt(T&&... args){((cout << args),...);}
template <typename... T>static inline void wt_n(T&&... args){((cout << args),...);cout<<"\n";}
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}
/*------------SOME USEFULL FUNCTIONS*---------*/




ll mpow(ll a, ll n)
{
    ll r = 1;
    while (n) {
        if (n&1) r = (r*a)%mod;
        a = (a*a)%mod;
        n >>= 1;
    }
    // loopa
    return r;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}




void solve(){
    ll  ax,ay,bx,by,fx,fy;
    gt(ax,ay,bx,by,fx,fy);
    ll cnt = 0;
    ll t1,t2;


    cnt += abs(ax - bx) + abs(ay - by);

    if(ax == fx && bx == fx){
        t1 = min(ay,by);
        t2 = max (ay,by);
    

        if(fy > t1 && fy < t2){
            cnt += 2;
        }
    }

    else if(ay == fy && by == fy){
        t1 = min(ax,bx);
        t2 = max(ax,bx);
    

        if(fx > t1 && fx < t2){
            cnt += 2;
        }
    }


    wt_n(cnt);



}



int main(){
    fast;
    ll t;
    int flag = 0;
   
   
    T(t){
        solve();
    }
     // cout << gcd(4,4);

}
