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

    return 0;
}

