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

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

typedef Point Vector;

struct Line{
  Point s,t;
  Line(){}
  Line(Point s,Point t) : s(s),t(t) {}
};

bool isOrthogonal(const Line &l1,const Line &l2){
  Vector a = l1.t-l1.s;
  Vector b = l2.t-l2.s;
  return equal(dot(a,b),0);
}

bool isParallel(const Line &l1,const Line &l2){
  Vector a = l1.t-l1.s;
  Vector b = l2.t-l2.s;
  return equal(cross(a,b),0);
}
 
int main(){
  int Q;
  cin >> Q;
  while(Q--){
    Line l1,l2;
    cin >> l1.s >> l1.t;
    cin >> l2.s >> l2.t;

    if(isOrthogonal(l1,l2)){
      cout << 1 << endl;
    }else if(isParallel(l1,l2)){
      cout << 2 << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}