#include <stdio.h>
#include <math.h>

#define EPS 1e-16

int main(void)
{
    int q;
    double x[4], y[4];
    double dx1, dy1, dx2, dy2;
    double m1, m2;
    int i;

    scanf("%d", &q);
    while (q-- > 0){
        for (i = 0; i < 4; i++){
            scanf("%lf %lf", &x[i], &y[i]);
        }
        dx1 = x[1] - x[0];
        dy1 = y[1] - y[0];
        dx2 = x[3] - x[2];
        dy2 = y[3] - y[2];
        m1 = dy1 / dx1;
        m2 = dy2 / dx1;

        if (fabs(m1 - m2) < EPS){
            printf("2\n");
        }
        else if (fabs(dx1 * dx2 + dy1 * dy2) < EPS){
            printf("1\n");
        }
        else {
            printf("0\n");
        }
    }

    return (0);
}