Isolated Segments
Problem
You're given \(n\) segments in the rectangular coordinate system. The segments are defined by start and end points \((X_i, Y_i)\) and \((X_j , Y_j )\) \((1 ≤ i, j ≤ n)\). The coordinates of these points are integer numbers with real value smaller than 1000. The length of each segment is positive.
When 2 segments don't have a common point then it is said that segments don't collide. In any other case segments collide. Be aware that segments collide even if they have only one point in common.
A segment is said to be isolated if it doesn't collide with all the other segments that are given, i.e. segment \(i\) is isolated when for each \(1 ≤ j ≤ n, (i \neq j)\), segments \(i\) and \(j\) don't collide.
You are asked to find the number \(T\) - how many segments are isolated.
Input
The first line of input contains a number \(N\) \((N ≤ 50)\), then the tests follow. The first line of each test case contains the number \(M\) \((M ≤ 100)\) - the number of segments for this test case to be considered.
For this particular test case \(M\) lines follow each containing a description of one segment.
A segment is described by 2 points:
A start point \((X_{pi}, Y_{pi})\) and end point \((X_{ei}, Y_{ei})\). They are given in such order: \(X_{pi}\) \(Y_{pi}\) \(X_{ei}\) \(Y_{ei}\)
Output
For each test case output one line containing the number \(T\).
Sample
Input
6
3
0 0 2 0
1 -1 1 1
2 2 3 3
2
0 0 1 1
1 0 0 1
2
0 0 0 1
0 2 0 3
2
0 0 1 0
1 0 2 0
2
0 0 2 2
1 0 1 1
2
1 3 1 5
1 0 1 6
Output
1
0
2
0
0
0
Comments