#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int t;
    
    cin >> t;
    
    while(t--)
    {
        int xa, ya, xb, yb, xf, yf;
        
        cin >> xa >> ya >> xb >> yb >> xf >> yf;
        
        if(xa==xb && xb==xf && yf > ya && yf < yb)
        {
            cout << abs(yb-ya) + 2 << endl;
            continue;
        }
        
        else if(xa==xb && xb==xf && yf < ya && yf > yb)
        {
            cout << abs(yb-ya) + 2 << endl;
            continue;
        }
        
        else if(ya==yb && yb==yf && xf>xa && xf<xb)
        {
            cout << abs(xb-xa) + 2 << endl;
            continue;
        }
        
        else if(ya==yb && yb==yf && xf<xa && xf>xb)
        {
            cout << abs(xb-xa) + 2 << endl;
            continue;
        }
        
        else
        {
            cout << abs(xb-xa) + abs(yb-ya) << endl;
            continue;
        }
    }
}