#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit


namespace Geometory {
    const double EPS = 1e-10;

    inline bool equals(double a, double b) {
        return fabs(a - b) < EPS;
    }

    struct Point {
        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);
        }

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

        double abs() const {
            return sqrt(norm());
        }

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

        double cross(Point p) {
            return x * p.y - y * p.x;
        }

        bool operator<(const Point &p) const {
            return x != p.x ? x < p.x : y < p.y;
        }

        bool operator==(const Point &p) const {
            return equals(x, p.x) && equals(y, p.y);
//            return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
        }


    };

    using Vector = Point;

    struct Segment {
        Point p1, p2;

        Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

        Segment(double x1, double y1, double x2, double y2) : p1(x1, y1), p2(x2, y2) {}
    };

    using Line = Segment;


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

    double abs(Vector a) {
        return sqrt(norm(a));
    }

    double dot(Vector a, Vector b) {
        return a.dot(b);
    }

    double cross(Vector a, Vector b) {
        return a.cross(b);
    }

    //直行判定
    bool is_orthogonal(Vector a, Vector b) {
        return equals(dot(a, b), 0.0);
    }

    bool is_orthogonal(Point a1, Point a2, Point b1, Point b2) {
        return is_orthogonal(a1 - a2, b1 - b2);
    }

    bool is_orthogonal(Segment s1, Segment s2) {
        return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
    }

    //平行判定
    bool is_parallel(Vector a, Vector b) {
        return equals(cross(a, b), 0.0);
    }

    bool is_parallel(Point a1, Point a2, Point b1, Point b2) {
        return is_parallel(a1 - a2, b1 - b2);
    }

    bool is_parallel(Segment s1, Segment s2) {
        return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
    }


    struct Circle {
        Point c;
        double r;

        Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
    };

    using Polygon = vector<Point>;

    std::ostream &operator<<(std::ostream &os, const Point &p) {
        os << "(" << p.x << ", " << p.y << ")" << endl;
        return os;
    }

};

using namespace Geometory;


class Solve {
public:
    void solve() {
        Int q;
        cin >> q;
        while (q--) {
            Int x1, x2, x3, x4;
            Int y1, y2, y3, y4;
            cin >> x1 >> y1 >> x2 >> y2;
            Segment s1(x1, y1, x2, y2);
            cin >> x3 >> y3 >> x4 >> y4;
            Segment s2(x3, y3, x4, y4);

            if (is_orthogonal(s1, s2)) {
                cout << "1" << endl;
            } else if (is_parallel(s1, s2)) {
                cout << "2" << endl;
            } else {
                cout << "0" << endl;
            }
        }
    }

};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3220