/// Author :Nguyễn Thái Sơn -Ti20 -THPT chuyên Lương Thế Vinh

#include<bits/stdc++.h>
#define fi first
#define se second
#define TASK "test"
#define pb push_back
#define ti20_ntson int main()
#define in(x) cout << x << endl
#define all(x) (x).begin(),(x).end()
#define getbit(x, i) (((x) >> (i)) & 1)
#define cntbit(x) __builtin_popcount(x)
#define forup(i,l,r) for (int i=l; i<=r; i++)
#define fordown(i,l,r) for (int i=l; i>=r; i--)
#define debug(a,n) for (int i=1; i<=n; i++) cout << a[i] << " "; cout << endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> vii;
typedef unsigned long long ull;
typedef vector<vector<int>> vvi;

const int N = 1e6+1;
const int mod = 1e9+7;
const int oo = INT_MAX;

int n, x[5], y[5];

inline void nhap()
{
    int ans =0;
    for (int i=1; i<=3; i++)
        cin >> x[i] >> y[i];
    if (x[1] == x[2] && x[2] == x[3] && max(y[1],y[2]) >= y[3] && min(y[1],y[2]) <= y[3]) ans+=2;
    if (y[1] == y[2] && y[2] == y[3] && max(x[1],x[2]) >= x[3] && min(x[1],x[2]) <= x[3]) ans+=2;
    ans = ans + abs(x[1] - x[2]) + abs(y[1] - y[2]);
    cout << ans << endl;
}

inline void solve()
{

}

ti20_ntson
{
//    freopen(TASK".INP","r",stdin);
//    freopen(TASK".OUT","w",stdout);
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    int T =1;
    cin >> T;
    while (T--) {
        nhap();
        solve();
    }
}

