#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		double x0, x1, x2, x3, y0, y1, y2, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double p1x, p1y, p2x, p2y;
		p1x = x1 - x0;
		p1y = y1 - y0;
		p2x = x3 - x2;
		p2y = y3 - y2;

		double u1x, u1y, u2x, u2y;
		u1x = p1x / sqrt(p1x*p1x + p1y*p1y);
		u1y = p1y / sqrt(p1x*p1x + p1y*p1y);
		u2x = p2x / sqrt(p2x*p2x + p2y*p2y);
		u2y = p2y / sqrt(p2x*p2x + p2y*p2y);

		double dot = (u1x*u2x + u1y*u2y);

		if (abs(dot) <= 0.000000000000001)
		{
			cout << "1" << endl;
		}
		else if (abs(abs(dot) - 1) <= 0.000000000000001)
		{
			cout << "2" << endl;
		}
		else
		{
			cout << "0" << endl;
		}
	}

	return 0;
}
