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

double get_radian(double x1, double y1, double x2, double y2) {
	if(fabs(x1-x2) < 0.00000001f) {
		if(fabs(y1-y2) < 0.00000001f) {
			return 0.0f;
		} else if(y1 > y2) {
			return 3 * M_PI / 2;
		} else {
			return M_PI / 2;
		}
	} else if(fabs(y1-y2) < 0.00000001f) {
		if(fabs(x1-x2) < 0.00000001f) {
			return 0.0f;
		} else if(x1 > x2) {
			return M_PI;
		}
		return 0.0;
	}
	
	if(x2 >= x1) {
		if(y2 >= y1) {
			return atan((y2-y1)/(x2-x1));
		}
		return 2 * M_PI + atan((y2-y1)/(x2-x1));
	} else {
		if(y2 >= y1) {
			return M_PI - atan((y2-y1)/(x1-x2));
		}
		return M_PI + atan((y2-y1)/(x2-x1));
	}
}

int main(void) {
	double x1,x2,x3,x4,y1,y2,y3,y4;
	double rad1, rad2;
	double rdiff;
	int i, n;
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		rad1 = get_radian(x1, y1, x2, y2);
		rad2 = get_radian(x3, y3, x4, y4);
		
		rdiff = fmod(2*M_PI+rad1-rad2, M_PI);

		if(fabs(rdiff) < 0.0001 || fabs(rdiff-M_PI) < 0.0001) {
			printf("2\n");
		} else if(fabs(rdiff-M_PI/2) < 0.0001) {
			printf("1\n");
		} else {
			printf("0\n");
		}
	}
	
	return 0;
}