#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "math.h"
#include <iostream>
using namespace std;


void main()
{
	FILE *in;
   float x1,x2,y1,y2,z,x0,y0,t;
	in=fopen("segment.in","r");
	fscanf(in,"%f",&t);
	for(int i=0;i<t;i++)
	{
	fscanf(in,"%f",&x1);
	fscanf(in,"%f",&y1);
	fscanf(in,"%f",&x2);
	fscanf(in,"%f",&y2);
	x0=abs(x2-x1);
	y0=abs(y2-y1);
	if (x2==x1)
	{
		z=abs(x2-x1)+1;
	}
	if (y2==y1)
	{
		z=abs(y2-y1)+1;
	}
	
	z=2;
	for (int i=x1+1; i<x2; i++)
	{
		for(int j=y1+1; j<y2; j++)
		{
			if(((i-x1)/x0)==((j-y1)/y0))
			{
				z=z+1;
			}
		}
	}
	cout<<z<<endl;
	}
	fclose(in);
}