#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here


template<class t>
class Vector2{
	public:
		t x;
		t y;
		Vector2():x(0), y(0){}
		Vector2(t a, t b):x(a), y(b){}
		Vector2(const Vector2 &o):x(o.x), y(o.y){}

		Vector2& operator+=(Vector2 o){x+=o.x;y+=o.y;return *this;}
		Vector2& operator-=(Vector2 o){x-=o.x;y-=o.y;return *this; }
		Vector2& operator*=(t o){x*=o;y*=o;return *this;}
		Vector2& operator/=(t o){x/=o;y/=o;return *this;}

		Vector2 operator+(Vector2 o){return Vector2(*this)+=o;}
		Vector2 operator-(Vector2 o){return Vector2(*this)-=o;}
		Vector2 operator*(t o){return Vector2(*this)*=o;}
		Vector2 operator/(t o){return Vector2(*this)/=o;}

		double abs(){
			return sqrt(x*x+y*y);
		}

		Vector2 normal(){
			return (*this) / abs();
		}
};

template<class t>
double abs(Vector2<t> x){
	return x.abs();
}

template<class t>
double dot(Vector2<t> x, Vector2<t> y){
	return x.x * y.x + x.y * y.y;
}

template<class t>
double cross(Vector2<t> x, Vector2<t> y){
	return x.x * y.y - x.y * y.x;
}

template<class t>
void output(Vector2<t> x){
	printf("%lf %lf\n", x.x, x.y);
}


template<class t>
class straight_line{
	public:
		using vector2 = Vector2<t>;
		vector2 f;
		vector2 s;
		straight_line(){
			f = vector2(0,0);
			s = vector2(1,0);
		}
		straight_line(vector2 a,vector2 b){
			f = a;
			s = b;
		}

		vector2 projection(vector2 pos){
			pos -= f;
			vector2 n = (s-f).normal();
			vector2 res;
			res = n * dot(pos,n) + f;
			return res;
		}

		vector2 reflection(vector2 pos){
			vector2 n;
			vector2 res;
			pos -= f;
			t x = f.y-s.y;
			t y = s.x-f.x;
			n = vector2(x,y).normal();
			res = pos + f - n * dot(pos,n) * 2;
			return res;
		}
};

using vector2 = Vector2<ll>;

vector2 input_vector2(){
	double x,y;
	cin >> x >> y;
	return vector2(x,y);
}

template<class t>
int cross_type(straight_line<t> a,straight_line<t> b){
	vector2 ap = a.s - a.f;
	vector2 bp = b.s - b.f;
	if(dot(ap,bp)==0)return 1;
	if(cross(ap,bp)==0)return 2;
	return 0;
}

int func(){
	straight_line<ll> a,b;
	a.f = input_vector2();
	a.s = input_vector2();
	b.f = input_vector2();
	b.s = input_vector2();
	return cross_type(a,b);
}

int main(){
	int q;
	cin >> q;
	rep(i,q){
		cout << func() << endl;
	}
}



Measured memory_bytes: 3228