#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a) for (int i=0; i<(a); i++)
#define FORI(i, a, b) for (int i=a; i<(b); i++)
#define FORd(i, a) for (int i=(a)-1; i>=0; i--)
#define FORId(i, a, b) for (int i=(a)-1; i>=(b); i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define printav(i, x) FOR(i, x.size()) cout << x[i] << " "; cout << "\n";
 
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
const int INF = 0x3f3f3f3f;
 
#define MAX 10
//int dp[MAX+1];

pi a,b,fi;

void solve()
{
    int sum = 0;

    int n1,n2;
    cin >> n1 >> n2;
    a = mp(n1,n2);
    cin >> n1 >> n2;
    b = mp(n1,n2);
    cin >> n1 >> n2;
    fi = mp(n1,n2);

    if (a.f == b.f and fi.f == a.f)
    {
        sum += abs(a.s-b.s);
        if (fi.s > (min(a.s,b.s)) and fi.s < (max(a.s,b.s)))
            sum += 2;
    }
    else if (a.s == b.s and fi.s == a.s)
    {
        sum += abs(a.f-b.f);
        if (fi.f > (min(a.f,b.f)) and fi.f < (max(a.f,b.f)))
            sum += 2;
    }
    else
    {
        sum += abs(a.f-b.f) + abs(a.s-b.s);
    }

    cout << sum << "\n";

}
 
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    //memset(dp, -1, sizeof(dp));

    int t = 1;
    cin >> t;

    while (t--)
    {
        solve();
        //cout << " -----------\n\n";
    }
    return 0;
}