#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define all(arr) (arr).begin(), (arr).end()
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) int((x).size())
#define fi first
#define se second
#define endl '\n'

bool between(int a, int l, int r){
  return a >= min(l, r) && a <= max(l, r);
}

void solve(){
  pair<int, int> A, B, C;
  cin >> A.fi >> A.se >> B.fi >> B.se >> C.fi >> C.se;
  if (A.fi == B.fi && A.fi == C.fi && between(C.se, A.se, B.se)){
    cout << abs(B.se - A.se) + 2 << endl;
    return;
  }
  if (A.se == B.se && A.se == C.se && between(C.fi, A.fi, B.fi)){
    cout << abs(B.fi - A.fi) + 2 << endl;
    return;
  }
  cout << abs(B.se - A.se) + abs(B.fi - A.fi) << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // cout.precision(20);
  int t;
  cin >> t;
  while (t--){
    solve();
  }
}