#include<bits/stdc++.h>
using namespace std;
int t;
struct node
{
int x, y;
}a, b, c;
int count(int & beg, int & end)
{
return beg - end;
}
bool check()
{
if ((a.x >= b.x && a.x >= c.x && a.y >= b.y && a.y >= c.y) || (a.x <= b.x && a.x <= c.x && a.y <= b.y && a.y <= c.y)) return true;
return false;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t --)
{
cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
int lbx = count(a.x, b.x);
int lby = count(a.y, b.y);
int lcx = count(a.x, c.x);
int lcy = count(a.y, c.y);
int ans = 0;
bool ikun = false, IKUN = false;
bool ngm = false, NGM = false;
if ((lbx ^ lcx) < 0)
{
ans += 1;
ngm = true;
}
else
{
ans += min(abs(lbx), abs(lcx));
if (check()) ikun = true;
}
if ((lby ^ lcy) < 0)
{
ans += 1;
NGM = true;
}
else
{
ans += min(abs(lby), abs(lcy));
if (check()) IKUN = true;
}
if (ikun && IKUN) ans ++;
if (ngm && NGM) ans --;
cout << ans << endl;
}
return 0;
}