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

int main()
{
    ll t;
    cin>>t;

    while(t--)
    {
        ll xa, xb, xf, ya, yb, yf;

        cin>>xa>>ya>>xb>>yb>>xf>>yf;

        if((xa == xb && xb == xf))
        {
            if(yb > ya)
            {
                swap(ya, yb);
            }
            if((yb < yf) &&(yf< ya))
            {
                cout<<abs(xa-xb)+abs(ya-yb)+2<<endl;
            }
            else
            {
                cout<<abs(xa-xb)+abs(ya-yb)<<endl;
            }
        }
        else if((ya == yb && yb == yf))
        {
            if(xb > xa)
            {
                swap(xa, xb);
            }
            if((xb < xf) &&(xf< xa))
            {
                cout<<abs(xa-xb)+abs(ya-yb)+2<<endl;
            }
            else
            {
                cout<<abs(xa-xb)+abs(ya-yb)<<endl;
            }
        }
        else
        {
            cout<<abs(xa-xb)+abs(ya-yb)<<endl;
        }
    }
    return 0;
}
