#include <bits/stdc++.h>   #define fasterio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)   #define X first   #define Y second   #define forn(i, n) for(int i=0;i<(n);i++)   #define pb push_back   using namespace std;   typedef long long ll;   typedef pair<int, int> pii;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9+7;   const long long maxn = 100010;      int gao (int x1, int y1, int x2, int y2, int xf, int yf) {    auto abs = [&](int a, int b){return a>b?a-b:b-a;};    int ans = abs(x1, x2) + abs(y1, y2);       if (x1 == x2 && y1 == y2) {     return ans;    } else if (x1 == x2 && x2 == xf) { // on the same x axis     if ((y1<yf && yf<y2) || (y2<yf && yf<y1))      ans += 2;    } else if (y1 == y2 && y2 == yf) {     if ((x1<xf && xf<x2)||(x2<xf && xf<x1))       ans += 2;    }    return ans;   }   int main() {    int t;    cin>>t;     while(t--) {     int xa, ya, xb, yb, xf, yf;     cin>>xa>>ya>>xb>>yb>>xf>>yf;          if(xa==xb && ya==yb) {      cout<<0<<endl;      continue;     }        int ans = gao(xa, ya, xb, yb, xf, yf);     cout<<ans<<endl;    }   }