using System;
using System.Collections.Generic;
using System.Linq;
// Q058 線分の平行と垂直の判定 https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=jp
class Program
{
static string InputPattern = "Input1";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("0 0 3 0 0 2 3 2");
WillReturn.Add("0 0 3 0 1 1 1 4");
WillReturn.Add("0 0 3 0 1 1 2 2");
//2
//1
//0
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
int X0 = wkArr[0];
int Y0 = wkArr[1];
int X1 = wkArr[2];
int Y1 = wkArr[3];
int X2 = wkArr[4];
int Y2 = wkArr[5];
int X3 = wkArr[6];
int Y4 = wkArr[7];
Solve(X0, Y0, X1, Y1, X2, Y2, X3, Y4);
}
}
static void Solve(int pX0, int pY0, int pX1, int pY1, int pX2, int pY2, int pX3, int pY3)
{
// 原点が始点になるように平行移動し、ベクトルで考える
int Vector1_X = pX1 - pX0;
int Vector1_Y = pY1 - pY0;
int Vector2_X = pX3 - pX2;
int Vector2_Y = pY3 - pY2;
// 内積が0なら 垂直
bool IsVertical = (Vector1_X * Vector2_X + Vector1_Y * Vector2_Y == 0);
// a1b2 - a2b1 = 0 なら平行
bool IsParallel = (Vector1_X * Vector2_Y - Vector1_Y * Vector2_X == 0);
if (IsParallel) {
Console.WriteLine(2);
}
else if (IsVertical) {
Console.WriteLine(1);
}
else {
Console.WriteLine(0);
}
}
}