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


ll t,xa,xb,ya,yb,xf,yf;
signed main(){
    cin >> t;
    while(t--){
        cin >> xa >> ya;
        cin  >>  xb >> yb;
        cin  >> xf >> yf;
       if((xa==xb && xa==xf) && (yf<max(ya,yb) && yf>min(ya,yb))){
            cout << abs(xa-xb) +abs(ya-yb) +2 << endl;
       }
       else if((ya==yb && yb ==yf) && (xf<max(xa,xb) && xf>min(xa,xb))){
            cout << abs(xa-xb)+ abs(ya-yb)+2 << endl;
       } else {
            cout << abs(xa-xb) + abs(ya-yb) << endl;
       }

    }


}
