#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
      int t;cin>>t;
      while(t--)
      {
          	int a1, a2, b1, b2, c1, c2;
	cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
	ll res = 0; 
	res += abs(a1 - b1) + abs(a2 - b2);
	if(c1 == a1 && c1 == b1)
		res += 2;
	else if (c2 == a2 && c2 == b2)
		res += 2;
	if (c1 == a1 && c1 == b1 && ((c2 > a2 && c2 > b2) || (c2 < a2 && c2 < b2)))
		res -= 2;
	else if (c2 == a2 && c2 == b2 && ((c1 > a1 && c1 > b1) || (c1 < a1 && c1 < b1)))
		res -= 2;
	cout << res << "\n";
      }
    return 0;
}