#include <bits/stdc++.h>
#define join_(a,b) join_again_(a,b)
#define join_again_(a,b) a ## b
#define rep(i,n) for(int i = 0, join_(lim, __LINE__) = n; i < join_(lim, __LINE__); ++i)
using C = std::complex<double>;
const double EPS = 1e-10;

// CGL_1_A
C projection(C p, C p1, C p2) {
    return C(((p-p1) / (p2-p1)).real(), 0.0) * (p2-p1) + p1;
}

void solve_CGL_1_A() {
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    C p1(x1,y1), p2(x2,y2);
    int q;
    std::cin >> q;
    rep(i,q) {
        int x, y;
        std::cin >> x >> y;
        C p = C(x,y);
        C res = projection(p, p1, p2);
        printf("%.20lf %.20lf\n", res.real(), res.imag());
    }
}

// CGL_1_B
C reflection(C p, C p1, C p2) {
    return std::conj(((p-p1) / (p2-p1))) * (p2-p1) + p1;
}

void solve_CGL_1_B() {
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    C p1(x1,y1), p2(x2,y2);
    int q;
    std::cin >> q;
    rep(i,q) {
        int x, y;
        std::cin >> x >> y;
        C p = C(x,y);
        C res = reflection(p, p1, p2);
        printf("%.20lf %.20lf\n", res.real(), res.imag());
    }
}

// CGL_1_C
// p0->p1 and p0->p2, query is p2
int counter_clockwise(C p0, C p1, C p2) {
    C a = std::conj(p1-p0) * (p2-p0);
    if (a.imag() >  EPS) { return +1; } // counter clockwise
    if (a.imag() < -EPS) { return -1; } // clockwise
    if (a.real() < -EPS) { return +2; } // p2-p0-p1
    if (std::norm(p1-p0) < std::norm(p2-p0)) { return -2; } // p0-p1-p2
    return 0; // p0-p2-p1
}
auto ccw = counter_clockwise;

void solve_CGL_1_C() {
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    C p0(x1,y1), p1(x2,y2);
    int q;
    std::cin >> q;
    rep(i,q) {
        int x, y;
        std::cin >> x >> y;
        C p2 = C(x,y);
        int res = counter_clockwise(p0, p1, p2);
        if (res == 1) {
            printf("COUNTER_CLOCKWISE\n");
        }
        if (res == -1) {
            printf("CLOCKWISE\n");
        }
        if (res == 2) {
            printf("ONLINE_BACK\n");
        }
        if (res == -2) {
            printf("ONLINE_FRONT\n");
        }
        if (res == 0) {
            printf("ON_SEGMENT\n");
        }
    }
}

// CGL_2_A
int parallel_orthogonal(C p0, C p1, C p2, C p3) {
    C a = (p3-p2) / (p1-p0);
    if (std::abs(a.real()) < EPS) { return 1; } // orthogonal
    if (std::abs(a.imag()) < EPS) { return 2; } // parallel
    return 0;
}

void solve_CGL_2_A() {
    int q;
    std::cin >> q;
    rep(i,q) {
        int xs[8];
        rep(k,8) {
            std::cin >> xs[k];
        }
        C p0 = C(xs[0], xs[1]);
        C p1 = C(xs[2], xs[3]);
        C p2 = C(xs[4], xs[5]);
        C p3 = C(xs[6], xs[7]);
        int res = parallel_orthogonal(p0, p1, p2, p3);
        printf("%d\n", res);
    }
}

// CGL_2_B
bool intersection(C p0, C p1, C p2, C p3) {
    return
        ccw(p0, p1, p2) * ccw(p0, p1, p3) <= 0 &&
        ccw(p2, p3, p0) * ccw(p2, p3, p1) <= 0;
}

void solve_CGL_2_B() {
    int q;
    std::cin >> q;
    rep(i,q) {
        int xs[8];
        rep(k,8) {
            std::cin >> xs[k];
        }
        C p0 = C(xs[0], xs[1]);
        C p1 = C(xs[2], xs[3]);
        C p2 = C(xs[4], xs[5]);
        C p3 = C(xs[6], xs[7]);
        bool res = intersection(p0, p1, p2, p3);
        printf("%d\n", res ? 1 : 0);
    }
}



int main() {
    solve_CGL_2_A();
}



Measured memory_bytes: 3236