#include <bits/stdc++.h>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point {
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y) {}
    Point operator + (Point p) {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) {return Point(x-p.x,y-p.y);}
    Point operator * (Point p) {return Point(x*p.x,y*p.y);}
    Point operator / (Point p) {return Point(x/p.x,y/p.y);}

    double abs() {return sqrt(norm());}
    double norm() {return x*x+y*y;}

    bool operator<(const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator==(const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;

double dot(Vector a,Vector b) {
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b) {
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Vector a,Vector b) {
    return equals(dot(a,b),0.0);
}

bool isPallalel(Vector a,Vector b) {
    return equals(cross(a,b),0.0);
}

int main(void) {
    int n;
    cin>>n;
Vector a1,a2,b1,b2;
    while(n) {
        cin>>a1.x>>a1.y>>a2.x>>a2.y>>b1.x>>b1.y>>b2.x>>b2.y;
        Vector s,t;
        s=a1-a2;
        t=b1-b2;
        if(isPallalel(s,t)) cout<<2<<endl;
        else if(isOrthogonal(s,t)) cout<<1<<endl;
        else cout<<0<<endl;
        n--;
    }
    return 0;
}