#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
using namespace std;

class Point {
    public:
    double x, y;

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

    double abs() {return sqrt(norm()); }
    double norm() {return x*x + y*y; }
};

typedef Point Vector;


double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

int main(){
    //cinの入力元をテキストファイルに(テスト用)
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        Point p0, p1, p2, p3;
        cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;

        Vector u = p1-p0;
        Vector v = p3-p2;

        double Dot = dot(u,v);
        double Cross = cross(u,v);
        
        int out;
        if(Cross==0){out = 2;} // Parallel
        else if (Dot==0){out = 1;} // Orthogonal
        else{out = 0;} //otherwise
        
        cout << out << "\n";
    }
    return 0;
}

