
#include <stdio.h>
#include <math.h>

int cross(double x0,double y0,double x1,double y1,double x2,double y2,double x3,double y3){
  double a0=0,a1=0;
  int b0=y1-y0;
  int b1=x1-x0;
  int b2=y3-y2;
  int b3=x3-x2;
  a0=(y1-y0)/(x1-x0);
  a1=(y3-y2)/(x3-x2);
  if(fabs(y2-y0)==fabs(y3-y1)) return 2; 
  else if((b0==0 && b3==0) || (b1==0 && b2==0)|| a0*a1==-1.0)    return 1;
  else return 0;
}


int main(){
  int number,i,m;
  double x0,y0,x1,y1,x2,y2,x3,y3;
  scanf("%d",&number);
  for(i=0;i<number;i++){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
    m=cross(x0,y0,x1,y1,x2,y2,x3,y3);
    printf("%d\n",m);

  }
  return 0;
}