#include <bits/stdc++.h>
using namespace std;
#pragma region defines
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pii>
#define si set<int>
#define pll pair<ll, ll>
#define pss pair<str, str>
#define vll vector<ll>
#define vstr vector<str>
#define vvll vector<vector<ll>>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define spll set<pll>
#define sll set<ll>
#define pld pair<ld, ld>
#define vld vector<ld>
#define vvld vector<vector<ld>>
#define vpld vector<pld>
#define sld set<ld>
#define PI 3.14159265358979323846
#define E  2.71828182845904523536
#define pout(x) cout << fixed << setprecision(x)
#define IOS ios::sync_with_stdio(0); cin.tie(0); std::cout.tie(0);
#define INF (ll)2009000999
#define F first
#define S second
#define pb push_back
#define in insert
#define mp make_pair
#define mod 1000000007
#define siz(x) (ll)x.size()
#define all(x) x.begin(), x.end()
#define alln(x, n) x.begin(), x.begin() + n
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef deque<bool> db;
typedef deque<int> di;
typedef string str;
#pragma endregion
void solve();
ll _, n, xa, ya, xb, yb, xf, yf;
string s;
void solve() {
    cin >> xa >> ya >> xb >> yb >> xf >> yf;
    if (xa != xb && ya != yb) cout << abs(xb - xa) + abs(yb - ya) << endl;
    else if (xa == xb) {
        if (xa == xf && yf >= min(ya, yb) && yf <= max(ya, yb)) {
            cout << abs(yb - ya) + 2 << endl;
        }
        else {
            cout << abs(yb - ya) << endl;
        }
    }
    else {
        if (ya == yf && xf >= min(xa, xb) && xf <= max(xa, xb)) {
            cout << abs(xb - xa) + 2 << endl;
        }
        else {
            cout << abs(xb - xa) << endl;
        }
    }
}
int main() {
    IOS;
    cin >> _;
    while (_--) {
        solve();
    }
}