#include<stdio.h>
int main()
{
    double q,i,x0,y0,x1,y1,x2,y2,x3,y3;
    scanf("%lf",&q);
    for(i=1;i<=q;i++)
    {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
        if((y0-y1)==0 && (x2-x3)==0)
            printf("1\n");
        else if((y1-y0)/(x1-x0)==(y2-y3)/(x2-x3))
            printf("2\n");
        else if((((y1-y0)/(x1-x0))*((y2-y3)/(x2-x3)))==-1)
            printf("1\n");
        else
            printf("0\n");
    }
    return 0;
}

