/*
    Author: MEHEDI ISLAM REMON
    AUST CSE 44th Batch

*/
#include<bits/stdc++.h>
#include<time.h>
#define ll      signed long long int
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(nullptr); cout.tie(nullptr);
#define pb      push_back
#define pi      acos(-1)
using namespace std;

bool compare(ll a,ll b)
{
    return a<b;
}

int main()
{
    fast;

    ll t;
    cin>>t;
    for(ll i=0; i<t; i++)
    {
        ll a1,a2,b1,b2,f1,f2;
        cin>>a1>>a2>>b1>>b2>>f1>>f2;
        ll large=0,large1=0;;
        ll small=0,small1=0;
        ll res=0;
        res=abs(a1-b1)+abs(a2-b2);
        if(a1==b1)
        {
            if(a2<=b2)
            {
                small=a2;
                large=b2;
            }
            else
            {
                small=b2;
                large=a2;
            }
            if(f1==a1 && f2>=small && f2<=large)
            {
                res+=2;
            }
        }
        else if(a2==b2)
        {
            if(a1<=b1)
            {
                small=a1;
                large=b1;
            }
            else
            {
                small=b1;
                large=a1;
            }
            if(f2==a2 && f1>=small && f1<=large)
            {
                res+=2;
            }
        }
        cout<<res<<endl;

    }

}
