#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int Ai,Aj,Fi,Fj,Bi,Bj;
        cin>>Ai>>Aj>>Bi>>Bj>>Fi>>Fj;
        if(Aj==Bj&&Aj==Fj)
        {
            int temp=Ai;
            Ai=Aj;
            Aj=temp;
            temp=Bi;
            Bi=Bj;
            Bj=temp;
            temp=Fi;
            Fi=Fj;
            Fj=temp;
        }
        if(Ai==Bi&&Ai==Fi)
        {
            if(Aj<Fj&&Fj<Bj)
            {
                cout<<Bj-Aj+2<<endl;
                continue;
            }
            else if(Bj<Fj&&Fj<Aj)
            {
                cout<<Aj-Bj+2<<endl;
                continue;
            }
            else
            {
                cout<<abs(Aj-Bj)<<endl;
                continue;
            }
        }
        cout<<abs(Aj-Bj)+abs(Ai-Bi)<<endl;
        
    }

    return 0;
}
