#include<iostream>
#include<cmath>
#define EPS (1e-10)
#define equal(a,b)  fabs((a)-(b))<EPS
using namespace std;
struct Point{
	double x,y;
	Point(double _x,double _y):x(_x),y(_y){  }
	Point operator + (Point &a){
		return Point(x+a.x,y+a.y);
	}
	Point operator - (Point &a){
		return Point(x-a.x,y-a.y);
	}
	Point operator *(double k){
		return Point (k*x,k*y);
	}
	Point operator /(double k){
		return Point(x/k,y/k);
	}
	
	friend double norm(Point &a){
		return a.x*a.x+a.y*a.y;
	}
	friend double abs(Point &a){
		return sqrt(norm(a));
	}
	
	friend double dot(Point &a,Point &b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(Point &a,Point &b){
		return fabs(a.x*b.y-b.x*a.y);
	}
};
typedef Point Vector;
bool isOrthogonal(Vector &a,Vector & b){
	return equal(cross(a,b),0.0);
}
bool isParallel(Vector &a,Vector &b){
	return equal(dot(a,b),0.0);
}

int main(){
	int q;
	cin>>q;
	while(q--){
		int x1,x2,y1,y2;
		cin>>x1>>y1>>x2>>y2;
		Vector v1(x1-x2,y1-y2);
		cin>>x1>>y1>>x2>>y2;
		Vector v2(x1-x2,y1-y2);
		if(isParallel(v1,v2)) cout<<1<<endl;
		else if(isOrthogonal(v1,v2)) cout<<2<<endl;
		else cout<<0<<endl;
	}
	return 0;
}
