#include<stdio.h>
#include<cmath>

int main(){
    int q;
    scanf("%d",&q);
    double x[2][2][q];
    double y[2][2][q];
    double p;
    double v;
    for(int i = 0; i < q; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[0][0][i], &y[0][0][i], &x[0][1][i], &y[0][1][i], &x[1][0][i], &y[1][0][i], &x[1][1][i], &y[1][1][i]);
        p = (x[0][1][i]-x[0][0][i])*(y[1][1][i]-y[1][0][i]) - (x[1][1][i]-x[1][0][i])*(y[0][1][i]-y[0][0][i]);
        v = (x[0][1][i]-x[0][0][i])*(x[1][1][i]-x[1][0][i]) + (y[1][1][i]-y[1][0][i])*(y[0][1][i]-y[0][0][i]);
        if (p < 0.000000001 && p > -0.000000001){
            printf("2\n");
        } else if (v < 0.000000001 && v > -0.000000001){
            printf("1\n");
        } else {
            printf("0\n");
        }
    }
}
