#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


class Point2D{
    double x, y;
public:
    Point2D(double X=0, double Y=0): x(X), y(Y){}
    Point2D(const Point2D& v): x(v.x), y(v.y){}
    template<class T>
    Point2D(const vector<T> &v){
        assert(v.size() == 2);
        x = v[0]; y = v[1];
    }
    template<class T, class T2>
    Point2D(const pair<T, T2> &p){
        x = p.first; y = p.second;
    }

    void setX(double X){x = X;}
    double getX(){return x;}
    void setY(double Y){y = Y;}
    double getY(){return y;}

    Point2D operator+() const{return *this;}
    Point2D operator-() const{return Point2D(-x, -y);}

    Point2D& operator=(const Point2D& v){
        x = v.x; y = v.y;
        return *this;
    }

    Point2D& operator+=(const Point2D& v){
        x += v.x; y += v.y;
        return *this;
    }

    Point2D& operator-=(const Point2D& v){
        x -= v.x; y -= v.y;
        return *this;
    }

    Point2D& operator*=(const double a){
        x *= a; y *= a;
        return *this;
    }

    Point2D& operator/=(const double a){
        x /= a; y /= a;
        return *this;
    }

    Point2D operator+(const Point2D& v) const{
        Point2D tmp(*this);
        return tmp += v;
    }

    Point2D operator-(const Point2D& v) const{
        Point2D tmp(*this);
        return tmp -= v;
    }

    Point2D operator*(const double a) const{
        Point2D tmp(*this);
        return tmp *= a;
    }

    friend Point2D operator*(double a, const Point2D v){
        return v * a;
    }

    Point2D operator/(const double a) const{
        Point2D tmp(*this);
        return tmp /= a;
    }

    double norm(){return x*x + y*y;}
    friend double norm(Point2D &v){return v.norm();}
    double abs(){return sqrt(norm());}
    friend double abs(Point2D &v){return v.abs();}

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

    bool operator>(const Point2D &v) const{
        return x != v.x ? x > v.x : y > v.y;
    }

    bool operator==(const Point2D &v) const{
        return std::abs(x - v.x) < EPS
            && std::abs(y - v.y) < EPS;
    }

    bool operator<=(const Point2D &v) const{
        return (*this < v) || (*this == v);
    }

    bool operator>=(const Point2D &v) const{
        return (*this > v) || (*this == v);
    }

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

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

    friend double distance(Point2D a, Point2D b){
        return (a - b).abs();
    }

    friend bool isParallel(Point2D a, Point2D b){
        return std::abs(cross(a, b)) < EPS;
    }

    friend bool isOrthogonal(Point2D a, Point2D b){
        return std::abs(dot(a, b)) < EPS;
    }
};
using Vector2D = Point2D;

class Line2D{
    Point2D p1, p2;
public:
    Line2D(){}
    Line2D(Point2D a, Point2D b): p1(a), p2(b){}

    void setP1(const Point2D p){p1 = p;}
    Point2D getP1(){return p1;}
    void setP2(const Point2D p){p2 = p;}
    Point2D getP2(){return p2;}

    friend Point2D project(Line2D l, Point2D p){
        Point2D base = l.p2 - l.p1;
        double r = dot(p - l.p1, base) / norm(base);
        return l.p1 + base * r;
    }

    friend Point2D reflect(Line2D l, Point2D p){
        return p + 2.0 * (project(l, p) - p);
    }

    friend bool isParallel(Line2D s1, Line2D s2){
        return isParallel(s1.p2 - s1.p1, s2.p2- s2.p1);
    }

    friend bool isOrthogonal(Line2D s1, Line2D s2){
        return isOrthogonal(s1.p2 - s1.p1, s2.p2- s2.p1);
    }
};



int main(){
    int q; cin >> q;
    REP(i, q){
        vector<Point2D> p(4);
        REP(j, 4){
            double x, y;
            cin >> x >> y;
            p[j].setX(x); p[j].setY(y);
        }
        cout << (isParallel(p[1] - p[0], p[3] - p[2]) ? 2 :
                (isOrthogonal(p[1] - p[0], p[3] - p[2]) ? 1 : 0)) << endl;
    }
    return 0;
}



Measured memory_bytes: 3236