For given set of triangles calculate how many pairs of them intersect.
Two triangles intersect if any segment of one triangle has at least one
point in common with any segment of the other triangle.
Input consists of several sets. Number of sets is given in the first line of input.
Each set starts with N (2<=N<=500), which is followed
by descriptions of N triangles. Each triangle i
(1<=i<=N) is described by six integers from range 0 to 10000:
X1i, Y1i, X2i,
Y2i, X3i, Y3i,
where pair (Xji,Yji) (for every j=1..3)
is a vertex of the triangle. Vetrices of one triangle are pairwise different
and are not colinear.
For each set output a line with one integer number saying how many pairs of triangles intersect.
3 2 1 2 3 1 3 3 4 1 4 3 6 2 2 1 2 3 1 3 3 1 1 1 3 3 2 4 0 0 2 0 0 2 2 0 0 2 2 2 0 2 2 2 0 0 2 2 0 0 2 0
0 1 6