 #include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back
#define f first
#define se second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define F0R(i, x) FOR(i, 0, x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
#define pii pair<int,int>
const int N=1000010;
const int mod=1e9+7;
 
/*
vector<int> p[N];
void sieve(){
	for(int i=2;i<N;i++){
		if(!p[i].size())
		for(int j=i+i;j<N;j+=i)
			p[j].pb(i);
	}
}
*/
 
double maxx(double a,double b)
{
    if(a>b)
        return a;
    else
        return b;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
     
}

int main()
{
    ll t;
    cin >> t;
    while(t--){
        ll xa, ya, xb, yb ,xf, yf;
        cin >> xa >> ya >> xb >> yb >> xf >> yf;
        int fg = 0;
        if((xa == xb && xa == xf )){
            if((yf>=ya && yf<=yb) || (yf<=ya && yf>=yb)) 
                fg = 1;
        }
        if((ya == yb && ya == yf )){
            if((xf>=xa && xf<=xb) || (xf<=xa && xf>=xb)) 
                fg = 1;
        }
        ll ans = abs(xb-xa) + abs(yb-ya);
        if(fg)
            ans +=2;
        cout << ans << endl;
        
    }
        
}
    