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 JAVA (judge verdict: Accepted)

public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int q;
    double[] xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
    int i;
    double s1x, s1y, s2x, s2y;

    q = sc.nextInt();
    xp0 = new double[q];
    yp0 = new double[q];
    xp1 = new double[q];
    yp1 = new double[q];
    xp2 = new double[q];
    yp2 = new double[q];
    xp3 = new double[q];
    yp3 = new double[q];

    for(i = 0;i < q;i++){
      xp0[i] = sc.nextDouble();
      yp0[i] = sc.nextDouble();
      xp1[i] = sc.nextDouble();
      yp1[i] = sc.nextDouble();
      xp2[i] = sc.nextDouble();
      yp2[i] = sc.nextDouble();
      xp3[i] = sc.nextDouble();
      yp3[i] = sc.nextDouble();
    }

    for(i = 0;i < q;i++){
      s1x = xp1[i] - xp0[i];
      s1y = yp1[i] - yp0[i];
      s2x = xp3[i] - xp2[i];
      s2y = yp3[i] - yp2[i];

      if((s1y * s2x) == (s2y * s1x)){
        System.out.println("2");
      }else if((s1x * s2x + s1y * s2y) == 0.0){
        System.out.println("1");
      }else{
        System.out.println("0");
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}