#include<stdio.h>

int main()
{
    int test;
    scanf("%d",&test);
    while(test--)
    {
        int x1,y1,x2,y2,x3,y3,x4,y4;
        scanf("%d%d%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        int X1,X2,Y1,Y2;
        if((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1)==0)
            printf("2\n");
        else if((y2-y1)*(y4-y3)+(x4-x3)*(x2-x1)==0)
            printf("1\n");
        else
            printf("0\n");

    }
}

