1607 - Triangles

Time Limit: 1s Memory Limit: 128MB

Submissions: 605 Solved: 161
You are given a figure consisting of n points in a 2D-plane and m segments connecting some of them. We guarantee that any two segments don't share points except their ends and there's no more than one segment between the same pair of points. Please count the total number of triangles in the given figure.
There're multiple test cases. In each case:
The first line contains two positive integers n and m. (n <= 200, m <= 20000)
Each of the following n lines contains two real numbers xi and yi  indicating the coordinates of the ith point. (-100000 < xi, yi < 100000)
Each of the following m lines contains four real numbers xi, yi, xj , yj . It means (xi, yi) and (xj , yj) are connected by a segment. We guarantee that these points are part of the given n points.
For each test case, print a single line contains the total number of triangles in the given figure. 
Please see sample for more details
Sample Input
4 5
0 0
1 1
2 0
1 0
0 0 1 1
1 1 2 0
2 0 1 0
1 0 0 0
1 1 1 0
Sample Output
The 7th(2012) ACM Programming Contest of HUST Problem Setter: Zhou Zhou