#include<bits/stdc++.h>
using namespace std;
struct point{
	double x,y;
	point(){}
	point(double _x,double _y){
		x=_x;y=_y;
	}
	point operator +(const point &b) const{
		return point(x+b.x,y+b.y);
	}
	point operator -(const point &b) const{
		return point(x-b.x,y-b.y);
	}
	double operator ^(const point &b) const{
		return (x*b.x)+(y*b.y);
	}
	double operator *(const point &b) const{
		return x*b.y-y*b.x;
	}
	point operator *(const double &b) const{
		return point(x*b,y*b);
	}
};
double len(point p){
	return (p.x*p.x+p.y*p.y);
}
int main(){
	point p0,p1,p2,p3;
	int q;
	cin>>q;
	while(q--){
		cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
		if((p1-p0)*(p3-p2)==0) puts("2");
		else if(((p1-p0)^(p3-p2))==0) puts("1");
		else puts("0");
	}
	return 0;
}
