#region ZIPPER
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using sc = Scanner;
using Geometry;
using gl = Geometry.GeometryLibrary;
class Program
{
    static void Main(string[] args)
    {
        Solver solver = new Solver();
        solver.Solve();
#if DEBUG
        System.Console.WriteLine("?¶?????????????????????????????????????????????????????????????");
        System.Console.ReadKey();
#endif

    }
}
/// <summary>
/// ?¨??????\????????????????????´???????????????????????????????????????
/// </summary>
public static class Scanner
{
    public static string NextString()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return tmp;
    }
    public static int NextInt()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return int.Parse(tmp);
    }
    public static long NextLong()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return long.Parse(tmp);
    }
    public static double NextDouble()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return double.Parse(tmp);
    }

    public static string[] NextStrArray()
    {
        return Console.ReadLine().Split(' ');
    }
    public static int[] NextIntArray()
    {

        string[] s = NextStrArray();
        int[] a = new int[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        return a;
    }
    public static long[] NextLongArray()
    {
        string[] s = NextStrArray();
        long[] a = new long[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = long.Parse(s[i]);
        }
        return a;
    }
    public static double[] NextDoubleArray()
    {
        string[] s = NextStrArray();
        double[] a = new double[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = double.Parse(s[i]);
        }
        return a;
    }
}
#endregion ZIPPER

public class Solver
{
#region IGNORE_ME
    public Solver()
    {
        //???????????¨?????????????????????????????????????????????
    }
#endregion IGNORE_ME

    public void Solve()
    {
        int q = sc.NextInt();
        Point[] p = new Point[4*q];
        for (int i = 0; i < 4*q; i++)
        {
            p[i] = new Point(sc.NextInt(), sc.NextInt());
        }
        for (int i = 0; i < q; i++)
        {
            int s = 4*i;
            if (gl.IsParallel(p[s], p[s + 1], p[s + 2], p[s + 3]))
            {
                Console.WriteLine("2");
            }
            else if (gl.IsVertical(p[s], p[s + 1], p[s + 2], p[s + 3]))
            {
                Console.WriteLine("1");
            }
            else
                Console.WriteLine("0");
        }
#if DEBUG
        Console.WriteLine("");//local check
#endif
    }
}
namespace Geometry
{
    /// <summary>
    /// ??????x,y??§?¨??????¨???(double???)
    /// </summary>
    public struct dPoint
    {
        public double x;
        public double y;
        public dPoint(int x, int y)
        {
            this.x = (double)x; this.y = (double)y;
        }
        public dPoint(double x, double y)
        {
            this.x = x; this.y = y;
        }
        public static dPoint operator +(dPoint p1, dPoint p2)
        {
            return new dPoint(p1.x + p2.x, p1.y + p2.y);
        }
        public static dPoint operator -(dPoint p1, dPoint p2)
        {
            return new dPoint(p1.x - p2.x, p1.y - p2.y);
        }
        public static dPoint operator *(double s, dPoint p)
        {
            return new dPoint(s * p.x, s * p.y);
        }
    }
    /// <summary>
    /// ??????x,y??§?¨??????¨???(int???)
    /// </summary>
    public struct Point
    {
        public int x;
        public int y;
        public Point(int x, int y)
        {
            this.x = x; this.y = y;
        }
        public static Point operator +(Point p1, Point p2)
        {
            return new Point(p1.x + p2.x, p1.y + p2.y);
        }
        public static Point operator -(Point p1, Point p2)
        {
            return new Point(p1.x - p2.x, p1.y - p2.y);
        }
        public static Point operator *(int s, Point p)
        {
            return new Point(s * p.x, s * p.y);
        }
    }

    public static class GeometryLibrary
    {


        /// <summary>
        /// ??????
        /// </summary>
        /// <returns></returns>
        public static double Naiseki(dPoint p1, dPoint p2)
        {
            return p1.x * p2.x + p1.y * p2.y;
        }
        /// <summary>
        /// ??????
        /// </summary>
        /// <returns></returns>
        public static int Naiseki(Point p1, Point p2)
        {
            return p1.x * p2.x + p1.y * p2.y;
        }
        /// <summary>
        /// ??´???p1,p2???????????????p????°???±
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static dPoint Projection(dPoint p1, dPoint p2, dPoint p)
        {
            dPoint a = p2 - p1;
            dPoint b = p - p1;
            double t = Naiseki(a, b) / Naiseki(a, a);
            return t * a + p1 ;
        }
        /// <summary>
        /// ??´???p1p2???????????????p???????°????p1,p2???????????´?????????????§°??????p????§????
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static dPoint Refrection(dPoint p1, dPoint p2, dPoint p)
        {
            return 2 * Projection(p1, p2, p) - p;
        }

        /// <summary>
        /// p1p2??¨p3p4????????´????????????
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p3"></param>
        /// <param name="p4"></param>
        /// <returns></returns>
        public static bool IsParallel(Point p1, Point p2, Point p3, Point p4)
        {
            Point a = p2 - p1;
            Point b = p4 - p3;
            if (Naiseki(a, b) * Naiseki(a, b) == Naiseki(a, a) * Naiseki(b, b)) return true;
            return false;
        }
        public static bool IsVertical(Point p1, Point p2, Point p3, Point p4)
        {
            Point a = p2 - p1;
            Point b = p4 - p3;
            if (Naiseki(a, b) == 0) return true;
            return false;
        }
    }
}

Measured memory_bytes: 7520