#include <iostream>

using namespace std;
int q;
struct point
{
    double x,y;
};
point vt(point a,point b)
{
    point vt;
    vt.x=b.x-a.x;
    vt.y=b.y-a.y;
    return vt;
}
void test(point a,point b)
{
    if (a.x*b.y==a.y*b.x) cout<<2<<endl;
    else if (a.x*b.x+a.y*b.y==0) cout<<1<<endl;
    else cout<<0<<endl;
}
int main()
{
    cin>>q;
    while (q--)
    {
        point p0,p1,p2,p3;
        cin>>p0.x>>p0.y>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y;
        point p01=vt(p0,p1);
        point p23=vt(p2,p3);
        test(p01,p23);
    }
    return 0;
}

