#include<bits/stdc++.h>
#define eps (1e-10)
using namespace std;
class Point
{
	public:
	double x,y;
	Point(double _x=0,double _y=0):x(_x),y(_y){}
	Point operator -(Point p){
		return Point(x-p.x,y-p.y);
	}
};
bool solve1(Point a,Point b)
{
	double f=a.x*b.x+a.y*b.y; 
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
bool solve2(Point a,Point b)
{
	double f=a.x*b.y-a.y*b.x;
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
int main()
{
	int T;scanf("%d",&T);
	while(T--){
		double p1_x,p1_y,p2_x,p2_y,p3_x,p3_y,p4_x,p4_y;
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&p1_x,&p1_y,&p2_x,&p2_y,&p3_x,&p3_y,&p4_x,&p4_y);
		Point a1(p1_x,p1_y),a2(p2_x,p2_y),b1(p3_x,p3_y),b2(p4_x,p4_y);
		if(solve1(a1-a2,b1-b2)) printf("1\n");
		else if(solve2(a1-a2,b1-b2)) printf("2\n");
		else printf("0\n");
		
	}
	return 0;
}
