#include <stdio.h>
#include <math.h>
#define y1 y11111

double x1,y1,x2,y2,x3,y3,x4,y4;
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		x2-=x1;
		y2-=y1;
		x4-=x3;
		y4-=y3;
		int r=x2*x4+y2*y4;
		int c=x2*y4-x4*y2;
		if(r==0)puts("1");
		else if(c==0)puts("2");
		else puts("0");
	}
}
