#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

class Vector2{
  public:
  int x, y;
  Vector2(){}
  Vector2(int x, int y): x(x), y(y) {}

  Vector2 operator + (Vector2 v) {
    return Vector2(x + v.x , y + v.y);
  }
  Vector2 operator - (Vector2 v) {
    return Vector2(x - v.x , y - v.y);
  }

};

int dot(Vector2 a, Vector2 b){
  return a.x * b.x + a.y * b.y; 
}

int cross(Vector2 a, Vector2 b){
  return a.x * b.y - a.y*b.x;
}

int main(){
  Vector2 v_1, v_2,p_1,p_2;
  int n,dot_, cross_;
  cin >> n;
  rep(i,n){
    cin >> p_1.x >> p_1.y >> p_2.x >> p_2.y;
    v_1 = p_2 - p_1;
    cin >> p_1.x >> p_1.y >> p_2.x >> p_2.y;
    v_2 = p_2 - p_1;
    dot_ = dot(v_1, v_2);
    cross_ = cross(v_1, v_2);
    if(dot_ == 0) cout << 1;
    else if(cross_ == 0) cout << 2;
    else cout << 0;
    cout << endl;
  }

  return 0;
}
