#include <iostream>
#include <complex>

const double tol = 1e-15;

int main() {
  int q;
  std::cin >> q;

  for (int i = 0; i < q; ++i) {
    double x0, y0, x1, y1, x2, y2, x3, y3;
    std::cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    double ip = (x1 - x0) * (x3 - x2) + (y1 - y0) * (y3 - y2);
    double norm1 = std::sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
    double norm2 = std::sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
    double theta = ip / norm1 / norm2;

    int result = 0;
    if (std::abs(theta) < tol) {
      result = 1;
    } else if (std::abs(theta) > 1 - tol) {
      result = 2;
    }

    std::cout << result << std::endl;
  }

  return 0;
}
