/* 
    Please teach Jee Chemistry :(

*/

// #define _GLIBCXX_DEBUG
// #pragma GCC optimize "trapv"
#include <bits/stdc++.h> 
using namespace std;

#pragma GCC target ("avx")    
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define rep(i,a) for(int i=0;i<a;i++)
#define per(i,a) for(int i=a;i >= 0; i--)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define per1(i,a,b) for(int i=a;i >= b;i--)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)

using namespace std;
#define ll long long
int INF=1000000000;

void solve(){
    
    int a,b,c,d,e,f,k,k1;
    cin >> a >> b;
    cin >> c >> d;
    cin >> e >> f;
    int res = abs(a-c) + abs(b-d);
    if(a == c and a == e and min(b,d) < f and max(b,d) > f) res += 2;
    else if(b == d and b == f and min(a,c) < e and max(a,c) > e) res += 2;
    cout << res << '\n';

}
    
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;cin >> t;
    while(t-- > 0){
        solve();
    }
}
