/*
_____________¶¶¶¶¶¶¶
___________¶¶¶______¶¶¶
_________¶¶¶___________¶¶
________¶¶______________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶
_______¶¶___________________¶_______¶¶¶¶¶
______¶¶________________________________¶¶¶
_____¶¶___________________________________¶¶
____¶¶___________________¶¶________________¶¶
____¶¶___________________¶¶_________________¶
___¶¶____________________¶__________________¶
___¶¶___¶¶__________________________________¶
__¶¶__¶_¶¶¶¶¶_______________________________¶¶
__¶¶_¶¶¶¶¶¶¶¶¶______________________________¶¶¶
__¶__¶¶¶¶¶¶¶¶¶______________________________¶¶¶
__¶_¶¶¶¶¶¶¶¶¶¶¶¶___________________________¶¶
__¶_¶¶¶_¶¶¶_¶¶_¶¶_________________________¶¶
__¶_¶¶_¶¶¶¶¶¶¶¶_¶_______________________¶¶
__¶_¶¶__¶¶¶¶¶¶¶_¶¶___¶¶______________¶¶¶¶
__¶_¶¶__¶¶¶¶¶¶¶_¶¶____¶___________¶¶¶¶
__¶_¶¶¶¶¶¶¶__¶¶_¶¶_____¶¶¶¶___¶¶¶¶¶
___¶_¶¶¶¶¶¶__¶¶_¶__________¶¶¶¶
___¶¶__¶¶¶¶¶¶¶__¶¶¶¶______¶¶¶
____¶¶___¶¶¶___¶¶¶¶¶¶____¶¶
_____¶¶¶_____¶¶¶____¶_____¶¶¶
________¶¶¶¶¶¶_____¶¶¶¶¶¶¶¶¶
____________________¶¶_____¶¶
____________________¶_______¶¶
____________________¶________¶¶
___________________¶¶_________¶¶
___________________¶____¶¶_____¶¶
__________________¶¶____¶¶______¶¶
__________________¶_¶____¶_______¶¶
_________________¶¶_¶____¶¶______¶¶
___________¶¶¶¶__¶¶_¶_____¶______¶¶
____________¶¶¶¶¶¶¶_¶_____¶______¶¶
_____________¶¶__¶_¶______¶_____¶¶¶___¶¶¶
_______________¶¶¶_¶___¶__¶_____¶¶__¶¶¶_¶¶
_____________¶¶__¶_¶¶__¶_¶¶___¶¶___¶¶____¶¶
____________¶¶¶¶__¶_¶¶¶¶¶_____¶¶__¶¶_____¶¶
___________¶¶__¶¶¶¶____________¶¶¶_______¶¶
___________¶¶___¶¶____¶¶¶¶¶_____¶_____¶_¶¶
____________¶________¶____¶_____________¶¶
____________¶_______¶¶____¶¶______¶¶___¶¶
____________¶¶_______¶¶___¶¶________¶¶¶¶
_____________¶¶_______¶¶_¶¶_________¶¶
_____________¶¶__¶¶____¶¶_________¶¶
______________¶¶_¶¶_¶__¶_______¶¶¶¶
_______________¶¶¶__¶¶¶¶¶__¶¶¶¶¶
_________________¶¶¶¶¶__¶¶¶¶¶
*/

#include <bits/stdc++.h> // see /general/running-code-locally
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

#define arrsz(x) sizeof(x)/sizeof(x[0])

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define F0R(i, x) FOR(i, 0, x)
#define FORd(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define F0Rd(i, x) FORd(i, 0, x)

void setIO(string name = "") {
	cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
	if (sz(name)) {
		freopen((name+".in").c_str(), "r", stdin); // see /general/io
		freopen((name+".out").c_str(), "w", stdout);
	}
}
void solve() {
    int xa, ya, xb, yb, xf, yf;
    cin>>xa>>ya>>xb>>yb>>xf>>yf;
    if(((xa == xb && xb == xf) && (yf < max(ya, yb) && yf > min(ya, yb))) || ((ya == yb && yb == yf) && (xf < max(xa, xb) && xf > min(xa, xb)))) {
        cout<<abs(xb-xa) + abs(yb-ya)+2<<endl;
    }
    else {
        cout<<abs(xb-xa) + abs(yb-ya)<<endl;
    }
}
int main() {
    setIO();
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}