#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long 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 * (long double k) {
    return Point(x * k, y * k);
  }

  long double norm(Point p) {
    return p.x * p.x + p.y + p.y;
  }

  long double abs(Point p) {
    return sqrt(norm(p));
  }

  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;
  }
};

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int judge(Point v1, Point v2) {
  if (cross(v1, v2) == 0) return 2;
  else if (dot(v1, v2) == 0) return 1;
  else return 0;
}

int main() {
  int q;
  cin >> q;
  Point p0, p1, p2, p3, v1, v2;
  rep(i, q) {
    cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
    v1 = p1 - p0;
    v2 = p3 - p2;
    cout << judge(v1, v2) << endl;
  }

  
  return 0;
}
