#include <stdio.h>

int main() {
    int n, x0, y0, x1, y1, x2, y2, x3, y3;
    scanf("%d", &n);
    while(n--) {
        scanf("%d%d%d%d%d%d%d%d", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        if ((x1-x0) * (y3-y2) - (y1-y0) * (x3-x2) == 0) puts("2");
        else if ((x1-x0) * (x3-x2) + (y1-y0) * (y3-y2) == 0) puts("1");
        else puts("0");
    }
}

