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

int main()
{
    int t, xa, ya, xb, yb, xf, yf;
    scanf("%d",&t);
    while(t--)
    {
        int ans = 0;
        scanf("%d%d%d%d%d%d",&xa, &ya, &xb, &yb, &xf, &yf);
        if(xa == xb){
            if(xa == xf && (yf < ya && yf > yb || yf > ya && yf < yb)) ans += 2;
            ans += abs(yb - ya);
        }
        else if(ya == yb){
            if(ya == yf && (xf < xa && xf > xb || xf > xa && xf < xb)) ans += 2;
            ans += abs(xb - xa);
        }
        else ans += (abs(xb - xa)) + (abs(yb - ya));
        printf("%d\n",ans);
    }
    return 0;
}
