Criss-Cross

/problems/crisscross/file/statement/en/img-0001.png

Peter is bored during his operating systems class, so he draws doodles on a sheet of paper. He feels like drawing abstract art using his ruler: he draws line segments by choosing two points in the plane and connecting them. Lots of them.

Can you write a program that counts the number of distinct points at which the line segments he drew intersect or touch?

Input

The first line in the input contains an integer $n$ ($1 \le n \le 1\, 000$) which is the number of lines. The following $n$ lines contain four integers $x_0 \ \ y_0 \ \ x_1 \ \ y_1$ ($-1\, 000\, 000 \le x_0, \ y_0, \ x_1, \ y_1 \le 1\, 000\, 000$). Lines have non-zero length, i.e., the two points will be distinct: $x_0 \ne x_1$ or $y_0 \ne y_1$ or both.

Output

Output the number of distinct points for which there is at least one pair of line segments that intersects or touches at this point. If there are infinitely many such points, output -1.

Sample Input 1 Sample Output 1
3
1 3 9 5
2 2 6 8
4 8 9 3
3
Sample Input 2 Sample Output 2
3
5 2 7 10
7 4 4 10
2 4 10 8
1
Sample Input 3 Sample Output 3
3
2 1 6 5
2 5 5 4
5 1 7 7
1
Sample Input 4 Sample Output 4
2
-1 -2 -1 -1
-1 2 -1 -1
1
Sample Input 5 Sample Output 5
2
0 0 2 2
1 1 -5 -5
-1