#include "math.h"
#include <iostream>
#include <fstream>
using namespace std;

void main()
{
	ifstream F;
   float x1,x2,y1,y2,z,x0,y0,t,a,b;
   F.open("segment.in",ios::in);
	F>>t;
	for(int i=0;i<t;i++)
	{
	F>>x1>>y1>>x2>>y2;
	x0=abs(x2-x1);
	y0=abs(y2-y1);
	if(x2==x1)	z=abs(y2-y1)+1;
	else if(y2==y1) z=abs(x2-x1)+1;
	else
	{
	z=2;
	for (int i=x1+1; i<x2; i++)
	{
		for(int j=y1+1; j<y2; j++)
		{
			a=x0/(i-x1); b=y0/(j-y1);
			if(a==b)
			{
				z++;
			}
		}
	}
	}
	cout<<z<<endl;
	}
}