#include<cstdio>
using namespace std;
int n;
struct point{
    double x,y;
    point(double x=0,double y=0):x(x),y(y){}
}p[4];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        for(int j=0;j<4;++j){
            scanf("%lf%lf",&(p[j].x),&(p[j].y));                                                  //1.double要用%lf
        }
        point tp1(p[0].x-p[1].x,p[0].y-p[1].y),tp2(p[2].x-p[3].x,p[2].y-p[3].y);
        if((tp1.x*tp2.y-tp1.y*tp2.x-0)==0){
            printf("2\n");
        }else if((tp1.x*tp2.x+tp1.y*tp2.y)==0){
            printf("1\n");
        }else{
            printf("0\n");
        }
    }
    return 0;
}
