#include <bits/stdc++.h>

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro,...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro,nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro,nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro,nargs) macro ## nargs
#define DBN(...)        macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DBN1(a)         cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"

#define endl '\n'
#define DBN1D(x) cerr<<#x<<endl;for(auto _:x){cerr<<_<<" ";}cerr<<endl
#define DBN2D(x) cerr<<#x<<endl;for(auto _:x){for(auto __:_){cerr<<__<<" ";}cerr<<endl;}cerr<<"------"<<endl
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp(x,y) make_pair(x,y)
#define mpp(w,x,y,z) mp(mp(w,x),mp(y,z))
using namespace std;
typedef long long loli;
typedef vector<loli> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef pair<loli,loli> pll;
typedef pair<pll,pll> pllll;
typedef vector<pll> vpll;

bool line(int a,int f,int b){
    if(a<f && f<b)
        return true;
    if(a>f && f>b)
        return true;
    return false;

}

void solve(){

    pll a,b,f;
    cin>>a.first>>a.second>>b.first>>b.second>>f.first>>f.second;
    loli ans=abs(a.first-b.first)+abs(a.second-b.second);
    if((a.first==b.first && b.first==f.first && line(a.second,f.second,b.second)) || (a.second==b.second && b.second==f.second&& line(a.first,f.first,b.first)))
        ans+=2;
    cout<<ans<<endl;

}


int main(){
    int _;
    cin>>_;
    while(_--)
        solve();
    return 0;
}