#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(ll i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(arg),key)-begin(arg)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

using namespace std;

using R=long double;
const R EPS = 1E-11;
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}

using P=complex<R>;
constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

//?????? dot ?????? det
inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

using L=struct{P s,t;};

// ?°???± verify AOJ CGL_1_A
P proj(P o,P a,P b){ a-=o,b-=o; return a*real(b/a);}
P proj(L l,P p){ return l.s+proj(l.s,l.t,p);}
// ????°? verify AOJ CGL_1_B
P refl(L l,P p){ return R(2.0)*proj(l,p)-p;}
// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {//???a??¨???b???????????????????????????
	if (sgn(det(o,a,b)) > 0) return LEFT;    // counter clockwise
	if (sgn(det(o,a,b)) < 0) return RIGHT;   // clockwise
	if (sgn(dot(o,a,b)) < 0) return BACK;    // b--base--a on line
	if (sgn(norm(a)-norm(b)) < 0) return FRONT;   // base--a--b on line
	return ON;// base--b--a on line  a??¨b????????????????????????
}

// ?????´ ?????? verify AOJ CGL_2_A
bool vertical(L a, L b) {return sgn(dot(O,a.t-a.s,b.t-b.s))==0;}
bool parallel(L a, L b) {return sgn(det(O,a.t-a.s,b.t-b.s))==0;}

// ?????¨??´?????¨????????¢??£??????????????? (s??????????????????????????§?????????????¨±?????????)
bool eql(L a,L b){ return (parallel(a,b) && sgn(det(a.s,a.t,b.s))==0);}

// ???????????????verify AOJ CGL_2_B
bool iss(L a,L b,int ban=0){
	R s1=det(a.s,a.t,b.s)*det(a.s,a.t,b.t);
	R s2=det(b.s,b.t,a.s)*det(b.s,b.t,a.t);
	return sgn(s1)<=-ban&&sgn(s2)<=-ban;
}

// ?????? verify AOJ CGL_2_C
P cross(L a,L b){
	R s1=det(a.s,b.s,b.t);
	R s2=s1+det(a.t,b.t,b.s);
	return a.s+s1/s2*(a.t-a.s);
}
	
// ?????¢
// ?????¨??´???????????¢ verify AOJ CGL_2_D
R dlp(L l,P p){return abs(det(l.s,l.t,p))/abs(l.t-l.s);}

// ?????¨??????????????¢ verify AOJ CGL_2_D
R dsp(L s,P p){
	if(sgn(dot(s.s,s.t,p))<=0) return abs(p-s.s);
	if(sgn(dot(s.t,s.s,p))<=0) return abs(p-s.t);
	return dlp(s,p);
}

// ????????¨??????????????¢ verify AOJ CGL_2_D
R dss(L a,L b){return iss(a,b)?0:min({dsp(a,b.s),dsp(a,b.t),dsp(b,a.s),dsp(b,a.t)});}

// ????????????
bool ill(L a,L b){ return parallel(a,b)==false;}
bool iLS(L l,L s,int ban=0){ return sgn(det(l.s,l.t,s.s)*det(l.s,l.t,s.t))<=-ban;}

// ??´?????¨??´???????????¢
R dll(L a,L b){return ill(a,b)?0:dlp(a,b.s);}
// ?????¨??´?????¨????????¢??£????????¢
R dls(L l,L s){return iLS(l,s)?0:min(dlp(l,s.s),dlp(l,s.t));}

int main(void){
	int n;
	cin >> n;
	cout.precision(20);
	rep(i,n){
		P a,b,c,d;
		cin >> a >> b >> c >> d;
		L s1={a,b},s2={c,d};
		if(parallel(s1,s2))
			cout << 2 << endl;
		else if(vertical(s1,s2))
			cout << 1 << endl;
		else
			cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3232