#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
int main(){
    int t;
    cin >> t;
    while(t--){
        int x1,x2,x3,y1,y2,y3;
        cin >> x1 >> y1;
        cin >> x2 >> y2;
        cin >> x3 >> y3;
        int c = abs(x2-x1)+abs(y2-y1);
        if(y1==y3 && y2==y3 && x3<max(x1,x2) && x3>min(x1,x2))cout << c+2 << "\n";
        else if(x1==x3 && x2==x3 && y3<max(y1,y2) && y3>min(y1,y2))cout << c+2 << "\n";
        else cout << c << "\n";
    }
    return 0;
}