#include <stdio.h>

double sd(double a[2], double b[2]);

int main(void)
{
    double a[2], b[2], a1, a2;
    int n, i;

    scanf("%d",&n);
    for (i = 0; i < n; i++) {

        scanf("%lf%lf", &a[0], &a[1]);
        scanf("%lf%lf", &b[0], &b[1]);
        a1 = sd(a, b);

        scanf("%lf%lf", &a[0], &a[1]);
        scanf("%lf%lf", &b[0], &b[1]);
        a2 = sd(a, b);

        if (a1 == a2) {
            puts("2");
        } else if (a1 == 0 || a2 == 0) {
            if (a2 == 1000000007 || a1 == 1000000007 ) {
                puts("1");
            } else {
                puts("0");
            }
        } else {
            if (a1 - 0.0000000002 < 1/a2 && 1/a2 < a1 + 0.0000000002 ) {
                puts("1");
            } else {
                puts("0");
            }
        }

    }
    return 0;
}

double sd(double a[2], double b[2]) 
{
    double inf = 1000000007;
    if (a[0] == b[0]) {
        return inf;
    } else {
        return (b[1] - a[1]) / (b[0] - a[0]);
    }
}