SP112 SEGVIS - Horizontally Visible Segments
Description
There is a number of disjoint vertical line segments in the plane. We say that two segments are horizontally visible if they can be connected by a horizontal line segment that does not have any common points with other vertical segments. Three different vertical segments are said to form a triangle of segments if each two of them are horizontally visible. How many triangles can be found in a given set of vertical segments?
### Task
Write a program that:
- reads the description of a set of vertical segments,
- computes the number of triangles in this set,
- writes the result.
Input Format
The first line of the input contains exactly one positive integer d equal to the number of data sets, 1
Output Format
The output should consist of exactly d lines, one line for each data set. Line i should contain exactly one integer equal to the number of triangles in the i-th data set.