using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Aoj.CGL.Lib;
  
namespace Aoj.CGL.Chapter2A
{
    class Program
    {
        public static void Solve()
        {
            int n = int.Parse(Console.ReadLine());
   
            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
  
                var seg1 = new Segment(input[0],input[1],input[2],input[3]);
                var seg2 = new Segment(input[4],input[5],input[6],input[7]);
  
                int answer = 0;
                if (Segment.IsOrthogonal(seg1, seg2))
                    answer = 1;
                else if (Segment.IsParallel(seg1, seg2))
                    answer = 2;
  
                Console.WriteLine(answer);
            }
        }
  
        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("ComputationalGeometry/Input/02_Segment_Line_A_01.txt"));
            // var sw = new Stopwatch();
            // sw.Start();
  
            Solve();
  
            // Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
        }
    }
}
  
namespace Aoj.CGL.Lib
{
    using Line = Segment;

    using Polygon = List<Point>;

    public struct Point
    {
        private double _x;
        private double _y;

        public double X { get { return _x;} }
        public double Y { get { return _y;} }

        public Point(double x, double y)
        {
            _x = x;
            _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 *(Point p, double k)
        {
            return new Point(p.X * k, p.Y * k);
        }

        public static explicit operator Vector(Point p)
        {
            return new Vector(p.X, p.Y);
        }

        public static bool IsOrthogonal(Point a1, Point a2, Point b1, Point b2)
        {
            return Vector.IsOrthogonal((Vector)(a1 - a2), (Vector)(b1 - b2));
        }

        public static bool IsParallel(Point a1, Point a2, Point b1, Point b2)
        {
            return Vector.IsParallel((Vector)(a1 - a2), (Vector)(b1 - b2));
        }
    }

    public struct Segment
    {
        private Point _p1;
        private Point _p2;

        public Point P1 { get{ return _p1; } }
        public Point P2 { get{ return _p2; } }

        public Segment(Point p1, Point p2)
        {
            _p1 = p1;
            _p2 = p2;
        }

        public Segment(double x1, double y1, double x2, double y2)
        {
            _p1 = new Point(x1, y1);
            _p2 = new Point(x2, y2);
        }
        public static bool IsOrthogonal(Segment s1, Segment s2)
        {
            return Vector.IsOrthogonal((Vector)(s1.P1 - s1.P2), (Vector)(s2.P1 - s2.P2));
        }

        public static bool IsParallel(Segment s1, Segment s2)
        {
            return Vector.IsParallel((Vector)(s1.P1 - s1.P2), (Vector)(s2.P1 - s2.P2));
        }
    }

    public struct Circle
    {
        private Point _p;
        private double _r;

        public Point P { get { return _p; } }
        public double R { get { return _r; } }

        public Circle(Point p, double r)
        {
            _p = p;
            _r = r;
        }
    }

    public struct Vector
    {
        private double _x;
        private double _y;

        public double X { get { return _x;} }
        public double Y { get { return _y;} }

        public Vector(double x, double y)
        {
            _x = x;
            _y = y;
        }

        public double Norm()
        {
            return X * X + Y * Y;
        }

        public double Abs()
        {
            return Math.Sqrt(Norm());
        }

        public static Vector operator +(Vector v1, Vector v2)
        {
            return new Vector(v1.X + v2.X, v1.Y + v2.Y);
        }

        public static Vector operator -(Vector v1, Vector v2)
        {
            return new Vector(v1.X - v2.X, v1.Y - v2.Y);
        }

        public static Vector operator *(Vector v, double k)
        {
            return new Vector(v.X * k, v.Y * k);
        }

        public static double Dot(Vector v1, Vector v2)
        {
            return v1.X * v2.X + v1.Y * v2.Y;
        }

        public static double Cross(Vector v1, Vector v2)
        {
            return v1.X * v2.Y - v1.Y * v2.X;
        }

        public static bool IsOrthogonal(Vector v1, Vector v2)
        {
            return Dot(v1, v2) == 0.0;
        }

        public static bool IsParallel(Vector v1, Vector v2)
        {
            return Cross(v1, v2) == 0.0;
        }
    }
}

Measured memory_bytes: 9392