#include<stdio.h>
int a[9][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};
int x1,y1,x2,y2,sum;
void dfs(int x,int y,int t)
{
if(x==x2&&y==y2)
{
if(sum>t)
sum=t;
}
else
{
if(!a[x-1][y]&&x-1>=0)
{
a[x-1][y]=1;
dfs(x-1,y,t+1);
a[x-1][y]=0;
}
if(!a[x+1][y]&&x+1<9)
{
a[x+1][y]=1;
dfs(x+1,y,t+1);
a[x+1][y]=0;
}
if(!a[x][y-1]&&y-1>=0)
{
a[x][y-1]=1;
dfs(x,y-1,t+1);
a[x][y-1]=0;
}
if(!a[x][y+1]&&y+1<9)
{
a[x][y+1]=1;
dfs(x,y+1,t+1);
a[x][y+1]=0;
}
}
}
int main()
{
int s;
scanf("%d",&s);
while(s--)
{
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
sum=5000000;
dfs(x1,y1,0);
printf("%d\n",sum);
}
return 0;
}
int a[9][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};
int x1,y1,x2,y2,sum;
void dfs(int x,int y,int t)
{
if(x==x2&&y==y2)
{
if(sum>t)
sum=t;
}
else
{
if(!a[x-1][y]&&x-1>=0)
{
a[x-1][y]=1;
dfs(x-1,y,t+1);
a[x-1][y]=0;
}
if(!a[x+1][y]&&x+1<9)
{
a[x+1][y]=1;
dfs(x+1,y,t+1);
a[x+1][y]=0;
}
if(!a[x][y-1]&&y-1>=0)
{
a[x][y-1]=1;
dfs(x,y-1,t+1);
a[x][y-1]=0;
}
if(!a[x][y+1]&&y+1<9)
{
a[x][y+1]=1;
dfs(x,y+1,t+1);
a[x][y+1]=0;
}
}
}
int main()
{
int s;
scanf("%d",&s);
while(s--)
{
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
sum=5000000;
dfs(x1,y1,0);
printf("%d\n",sum);
}
return 0;
}