#include <iostream>
using namespace std;

typedef struct _Vector{
	int x,y;
}Vector;

int main(){
	Vector s1,s2;
	
	int q,x0,x1,x2,x3,y0,y1,y2,y3,i;
	
	for(cin>>q,i=q;i--;){
		
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		
		s1.x = x1-x0;
		s1.y = y1-y0;
		
		s2.x = x3-x2;
		s2.y = y3-y2;
		
		if(s1.x*s2.y - s1.y*s2.x == 0)cout<<2;
		else if(s1.x*s2.x + s1.y*s2.y == 0)cout<<1;
		else cout<<0;
		
		cout<<endl;
	}
}