#include <stdio.h>
#include <iostream>
#include <math.h>

int main()
{
	long t,n,a,b,x1,y1,x2,y2,cash, k = 0;
	freopen("SEGMENT.IN", "r", stdin);
	//freopen("2.IN", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i<n; ++i)
	{
		k = 0;
		scanf("%d %d %d %d", &x1,&y1,&x2,&y2);
		if (x1 > x2)
		{
				cash = x1;
				x1 = x2;
				x2 = cash;
		}
		if (y1 > y2)
		{
				cash = y1;
				y1 = y2;
				y2 = cash;
		}
		if (x1 - x2 != 0) 
		{
			double con = (double)(y1 - y2)/(double)(x1 - x2);
			for (int x = x1+1; x < x2; ++x)
				for (int y = y1 + 1; y < y2; ++y)
				{
					double c = (double)(y1 - y)/(double)(x1 - x);
					if (c == con) 
					{
						//printf("%d %d %f\n", x,y,c);
						++k;
					}
				}
		}
		else
		if (y1 - y2 != 0) 
		{
			//double con = (double) 0;
	//		for (int x = x1+1; x<x2; ++x)
				for (int y = y1+1; y<y2; ++y)
		//			if (((x1-x)/(y1-y)) == 0) 
						++k;
		}
		printf("%d\n", k+2);
	}
	

	return 0;
}
