#include<stdio.h>
int main(){
    int i, q, x1, y1, x2, y2, x3, y3, x4, y4;
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d%d%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if((y2-y1)*(x4-x3)+(y4-y3)*(x2-x1)==0)puts("2");
        else if((y2-y1)*(y4-y3)+(x2-x1)*(x4-x3)==0)puts("1");
        else puts("0");
    }
    return 0;
}
