#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
typedef long long int ll;
using namespace std;
const int MAX=5000+10;
const double eps=1e-8;
const double PI=acos(-1.0);

int sgn(double x)
{
    if (fabs(x)<eps) {
        return 0;
    }
    if (x<0) {
        return -1;
    }
    else return 1;
}
struct point
{
    double x,y;
    point(){}
    point(double _x,double _y)
    {
        x=_x;y=_y;
    }
    point operator -(const point &b)const
    {
        return point(x-b.x,y-b.y);
    }
    double operator ^(const point &b)const
    {
        return x*b.y-y*b.x;
    }
    double operator *(const point &b)const
    {
        return x*b.x+y*b.y;
    }
};
int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    int q;
    point p0,p1,p2,p3;
    scanf("%d",&q);
    while(q--){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p0.x,&p0.y,&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y);
        point l1=p0-p1;
        point l2=p2-p3;
        double cross=l1^l2;
        double dot=l1*l2;
        if (!sgn(dot)) {
            printf("1\n");
        }
        else if (!sgn(cross)){
            printf("2\n");
        }
        else{
            printf("0\n");
        }
    }
    return 0;
}