A serious man Larry, a professor of quantum physics at University of Minnesota, had a streak of bad luck. He learned that his wife wanted to ruin him, his daughter was stealing money from him for a plastic surgery, his son was having problems at school, and his university department was receiving libels upon him in anonymous letters.
But that was not all. The police arrested Larry's brother Arthur, who had lived in Larry's house for several month working on a mysterious book “The Mentaculus.” When Larry wanted to read the Mentaculus he found out that the book was a collection of a lunatic's drawings — all the pages were filled with strange geometric shapes.
On one of the pages Larry saw a multitude of points and circular arcs. He thought for a moment that the points and arcs formed grinning faces. Could it be true that there were no warm feelings in Arthur's heart but only cold sarcasm? Larry wanted to calculate the number of smileys on the page. Being a scientist, he introduced a rigorous definition: a circular arc PQR and a pair of points A and B form a smiley if the following conditions hold:
- the straight line PR separates the points A and B from the point Q;
- the angles APR, ARP, BPR and BRP are acute;
- the distance from the points A and B to the straight line PR is less than the doubled length of the segment PR;
- the straight line AB has no common points with the segment PR.
Help Larry calculate the number of smileys on the page.
Input
The first line contains the number of arcs n and the number of points m (1 ≤ n ≤ 100; 1 ≤ m ≤ 10000). In each of the following n lines, an arc is described by the coordinates of three points in the order in which they are located on the arc. It is guaranteed that the three points describing an arc are distinct and do not lie in the same straight line. Each of the following m lines contains the coordinates of the points. All the coordinates are integers not exceeding 10000 in absolute value. All the arcs and all the points are distinct.
Output
Output the number of smileys on the page of the Mentaculus.
Sample
input | output |
---|
2 7
-2 2 0 0 2 2
-2 -2 0 0 2 -2
-1 3
1 3
0 5
0 3
-1 -3
1 -3
2 -3
| 4
|
Problem Author: Alexey Samsonov (prepared by Viktor Kamashev)
Problem Source: Ural Championship 2011