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

#define PREC 1e-12

int main() {
    int x, y, x0, y0, x1, y1, x2, y2, x3, y3;
    int q;
    double v1x, v1y, v2x, v2y, cosa;
    int judge;

    scanf("%d", &q);
    
    while (q--) {
        scanf("%d %d %d %d %d %d %d %d",
              &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        v1x = x1 - x0;
        v1y = y1 - y0;
        v2x = x3 - x2;
        v2y = y3 - y2;
        cosa = (v1x*v2x + v1y*v2y) /
            (sqrt(v1x*v1x+v1y*v1y) * sqrt(v2x*v2x+v2y*v2y));

        if (fabs(cosa) < PREC) {
            judge = 1;
        }
        else if (fabs(fabs(cosa) - 1.0) < PREC) {
            judge = 2;
        }
        else {
            judge = 0;
        }
        printf("%d\n", judge);
    }
}