#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int ax,ay;
        int bx,by;
        int fx,fy;
        cin>>ax>>ay;
        cin>>bx>>by;
        cin>>fx>>fy;
        if(ax==bx&&bx==fx){
            if((fy>ay&&fy<by)||(fy<ay&&fy>by))
            cout<<abs(ay-by)+2<<endl;
            else{
                cout<<abs(ay-by)<<endl;
            }
        }
        else if(ay==by&&by==fy){
            if((fx>ax&&fx<bx)||(fx<ax&&fx>bx))
            cout<<abs(ax-bx)+2<<endl;
            else
                cout<<abs(ax-bx)<<endl;
        }
        else{
            cout<<abs(ax-bx)+abs(ay-by)<<endl;
        }
    }
    return 0;
}