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

int main() {
    long long int T, i, j, k, N, M, a, b, c, d, x, y, ans;
    cin>>T;
    
    while(T--) {
        cin>>a>>b>>c>>d>>x>>y;
        
        ans = 0;
        ans += abs(a-c);
        ans += abs(b-d);
        
        if((a==c && a==x && min(b, d) < y && max(b, d) > y) 
            || (b==d && b==y && min(a, c) < x && max(a, c) > x)) {
            ans += 2;
        }
        
        cout<<ans<<endl;
    }
	
	return 0;
}
