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
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();
	static final double ALLOWABLE_ERROR = 0.00000001;

	public static void main(String[] args) {
		int q = sc.nextInt();
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<q; i++) {
			double x0 = sc.nextDouble();
			double y0 = sc.nextDouble();
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			
			if(x0 == x1) {
				if(x2 == x3) {
					ans.append(2);
				} else if(y2 == y3) {
					ans.append(1);
				} else {
					ans.append(0);
				}
			} else if(y0 == y1) {
				if(x2 == x3) {
					ans.append(1);
				} else if(y2 == y3) {
					ans.append(2);
				} else {
					ans.append(0);
				}
			} else {
				double a1 = (y1 - y0) / (x1 - x0);
				double a2 = (y3 - y2) / (x3 - x2);
				
				if(Math.abs(a2 - a1) < ALLOWABLE_ERROR) {
					ans.append(2);
				} else if(Math.abs((a1 * a2) + 1) < ALLOWABLE_ERROR) {
					ans.append(1);
				} else {
					ans.append(0);
				}
			}
			
			ans.append("\n");
		}
		
		System.out.print(ans);
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}