#include<stdio.h>
int min_step = 1000000;
int c,d;
int map[][9]={{1,1,1,1,1,1,1,1,1},
{1,0,0,1,0,0,1,0,1},
{1,0,0,1,1,0,0,0,1},
{1,0,1,0,1,1,0,1,1},
{1,0,0,0,0,1,0,0,1},
{1,1,0,1,0,1,0,0,1},
{1,1,0,1,0,1,0,0,1},
{1,1,0,1,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1},
};
void count(int step, int x, int y)//step:当前步数,x:横坐标,y: 总坐标
{
int i;
int m, n;
// printf("%d %d\n",x,y);
if( min_step < step)//他在某一步已经超过了最小步数就不继续往下走了
return;
if(x == c && y == d )
min_step = step;//到达终点的时候,重新判断mix_step的值
else
{
for(i = 1; i <= 4; i ++)
{
m = x, n = y;//这里很巧妙,不能改变X,Y的值但是又要使调用的结果 是方向改变后的坐标值
if( i == 1)
n --;//down
else if ( i == 2)
m ++;//right
else if(i == 3)
n ++;//up
else
m --;//left
if( map[m][n] == 0)
{
map[m][n] = 1;
count(step + 1, m, n);
map[m][n] = 0;
}
}
}
}
int main ()
{
int a,b;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%d%d%d%d",&a,&b,&c,&d);
count(0,a,b);
printf("%d\n",min_step);
min_step = 10000;//注意这里每一次循环结束都要重置
}
return 0;
}