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.

Constraints

* 1 ≤ q ≤ 1000
* -10000 ≤ xpi, ypi ≤ 10000
* p0 ≠ p1 and p2 ≠ 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".

Example

Input

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


Output

2
1
0
from sys import stdin

class Vector:
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, k):
        return Vector(self.x * k, self.y * k)

    def __gt__(self, other):
        return self.x > other.x and self.y > other.y

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    # usually cross operation return Vector but it returns scalor
    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

class Segment:
    def __init__(self, p1=Vector(0, 0), p2=Vector(1, 1)):
        self.p1 = p1
        self.p2 = p2

def is_orthogonal(*args, **kwargs):
    # input two vectors with the startpoint (0, 0)
    if len(args) == 2:
        v1, v2 = args
        return v1.dot(v2) == 0
    # input two vectors with the startpoint (a1, b1) and endpoint (a2, b2)
    elif len(args) == 4:
        a1, a2, b1, b2 = args
        return is_orthogonal(a1 - a2, b1 - b2)
    # input two segments
    elif len(kwargs) == 2:
        v1 = kwargs['s1'].p1 - kwargs['s1'].p2
        v2 = kwargs['s2'].p1 - kwargs['s2'].p2
        return v1.dot(v2) == 0
    else:
        raise ArgsError

def is_parallel(*args, **kwargs):
    # input two vectors with the startpoint (0, 0)
    if len(args) == 2:
        v1, v2 = args
        return v1.cross(v2) == 0
    # input two vectors with the startpoint (a1, b1) and endpoint (a2, b2)
    elif len(args) == 4:
        a1, a2, b1, b2 = args
        return is_parallel(a1 - a2, b1 - b2)
    # input two segments
    elif len(kwargs) == 2:
        v1 = kwargs['s1'].p1 - kwargs['s1'].p2
        v2 = kwargs['s2'].p1 - kwargs['s2'].p2
        return v1.cross(v2) == 0
    else:
        raise ArgsError

from sys import stdin

def read_and_print_results(n):
    for _ in range(n):
        line = stdin.readline().strip().split()
        p0 = Vector(int(line[0]), int(line[1]))
        p1 = Vector(int(line[2]), int(line[3]))
        p2 = Vector(int(line[4]), int(line[5]))
        p3 = Vector(int(line[6]), int(line[7]))
        s1 = Segment(p0, p1)
        s2 = Segment(p2, p3)
        if is_parallel(s1=s1, s2=s2):
            print('2')
        elif is_orthogonal(s1=s1, s2=s2):
            print('1')
        else:
            print('0')

n = int(input())
read_and_print_results(n)
