// CGL_2_A
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

struct vec{
	int x;
	int y;
};

struct point{
	int x;
	int y;
};

double inner_p(struct vec a, struct vec b){
	return (a.x*b.x + a.y*b.y);
}

double cross_p(struct vec a, struct vec b){
	return (a.x*b.y - a.y*b.x);
}

int main(){
	point p[4];
	vec v[2];
	int q;

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>p[0].x>>p[0].y>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y;

		for(int j=0;j<2;j++){
			v[j].x = p[2*j+1].x - p[2*j].x;
			v[j].y = p[2*j+1].y - p[2*j].y;
		}

		if(cross_p(v[0], v[1]) == 0)
			cout<<"2"<<endl;
		else if(inner_p(v[0], v[1]) == 0)
			cout<<"1"<<endl;
		else
			cout<<"0"<<endl;
	}

	return 0;
}