#include <algorithm>
#include <complex>
#include <vector>
using namespace std;
const double eps = 1e-10;
#define EQ(a, b) (abs((a) - (b)) < eps)
using P = complex<double>;      // position
double dot(const P &a, const P &b) { return real(conj(a) * b); }
double cross(const P &a, const P &b) { return imag(conj(a) * b); }

bool is_orthogonal(P a1, P a2, P b1, P b2) {
    return EQ(dot(a1 - a2, b1 - b2), 0);
}
bool is_parallel(P a1, P a2, P b1, P b2) {
    return EQ(cross(a1 - a2, b1 - b2), 0);
}

#include <iostream>
int main() {
    int q; cin >> q;
    while (q--) {
        vector<P> ps;
        for (int i = 0; i < 4; i++) {
            int x, y; cin >> x >> y;
            ps.emplace_back(x, y);
        }
        if (is_parallel(ps[0], ps[1], ps[2], ps[3])) {
            cout << 2 << endl;
        } else if (is_orthogonal(ps[0], ps[1], ps[2], ps[3])) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}
