#include <bits/stdc++.h>

using namespace std;

class Point {
    public:
        double x, y;
        Point(double x = 0.0, double y = 0.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 k) { return Point(x * k, y * k); }
        Point operator / (double k) { return Point(x / k, y / k); }

        double friend norm(Point p) { return p.x * p.x + p.y * p.y; }
        double friend abs(Point p) { return sqrt(norm(p)); }
};
typedef Point Vector;
struct Segment {
    Point p1, p2;
};

double dot(Segment s1, Segment s2) {
    Vector v1 = s1.p2 - s1.p1, v2 = s2.p2 - s2.p1;
    return v1.x * v2.x + v1.y * v2.y;
}

double cross(Segment s1, Segment s2) {
    Vector v1 = s1.p2 - s1.p1, v2 = s2.p2 - s2.p1;    
    return v1.x * v2.y - v1.y * v2.x;
}

int main(void) {
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        Segment s[2];
        for (int j = 0; j < 2; j++)
            cin >> s[j].p1.x >> s[j].p1.y >> s[j].p2.x >> s[j].p2.y;
        if (!cross(s[0], s[1])) cout << "2\n";
        else if (!dot(s[0], s[1])) cout << "1\n";
        else cout << "0\n";
    }
    return 0;
}
