#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b,c,d,e,f;
        cin>>a>>b>>c>>d>>e>>f;
        int m=abs(a-c)+abs(b-d);
        if(a!=c&&b!=d)cout<<m<<endl;
        else
        {
            if((a==c&&a==e&&f>=min(b,d)&&f<=max(b,d))||(b==d&&b==f&&e>=min(a,c)&&e<=max(a,c)))cout<<m+2<<endl;
            else cout<<m<<endl;

        }
    }
}