Problem:
Parallel/Orthogonal

For given two lines s1 and s2, print "2" if they are parallel, "1" if they are orthogonal, or "0" otherwise.

s1 crosses points p0 and p1, and
s2 crosses points p2 and p3.

Input

The entire input looks like:

q (the number of queries)
1st query
2nd query
...
qth query

Each query consists of integer coordinates of the points p0, p1, p2, p3 in the following format:

xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3

Output

For each query, print "2", "1" or "0".

Constraints

1 ≤ q ≤ 1000

-10000 ≤ xpi, ypi ≤ 10000

p0 ≠ p1 and
p2 ≠ p3.

Sample Input 1

3
0 0 3 0 0 2 3 2
0 0 3 0 1 1 1 4
0 0 3 0 1 1 2 2

Sample Output 1

2
1
0

Solution in C# (judge verdict: Wrong Answer)

using System;
using System.Text;

namespace CGL_1_A_Projection
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputCount = int.Parse (Console.ReadLine ());

			StringBuilder output = new StringBuilder (inputCount * 2);

			for (int lp = 0; lp < inputCount; lp++)
			{
				int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				Vector2 segment1 = new Vector2 (inputNum[0], inputNum[1]) - new Vector2 (inputNum[2], inputNum[3]);
				Vector2 segment2 = new Vector2 (inputNum[4], inputNum[5]) - new Vector2 (inputNum[6], inputNum[7]);

				if (Vector2.IsParallel (segment1, segment2))
				{
					output.Append (2);
				}
				else if (Vector2.IsOrthogonal (segment1, segment2))
				{
					output.Append (1);
				}
				else
				{
					output.Append (0);
				}

				output.AppendLine ();
			}

			Console.Write (output);
		}
	}

	class Vector2
	{
		public Vector2 ( double x, double y )
		{
			this.X = x;
			this.Y = y;
		}

		public double X { private set; get; }
		public double Y { private set; get; }

		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}

		public double Length ()
		{
			return X * X + Y * Y;
		}
		public Vector2 Normalize ()
		{
			double length = this.Length ();
			return new Vector2 (X / length, Y / length);
		}
		public static double DotProduct ( Vector2 ob1, Vector2 ob2 )
		{
			Vector2 normalize1 = ob1.Normalize ();
			Vector2 normalize2 = ob2.Normalize ();

			return normalize1.X * normalize2.X +
				normalize1.Y * normalize2.Y;
		}
		public static double CrossProduct ( Vector2 ob1, Vector2 ob2 )
		{
			return ob1.X * ob2.Y - ob1.Y * ob2.X;
		}

		public static bool IsOrthogonal ( Vector2 ob1, Vector2 ob2 )
		{
			return DotProduct (ob1, ob2) == 0;
		}
		public static bool IsParallel ( Vector2 ob1, Vector2 ob2 )
		{
			return CrossProduct (ob1, ob2) == 0;
		}
	}
}