Given N segment obstacles in the first quadrant and M rays from the origin, count how many segments no ray intersects, including exact endpoint touches.
Hard8GeometrySortingBinary searchNo attempts yetTime limit2sMemory limit256 MBIn the near future, humanity can travel between stars and sets out to find a new home. After a long voyage the last wormhole is finally ahead, but it is full of radiation layers. If people pass through it as it is, many of them will be exposed to radiation.
Fortunately, humanity has a laser that can destroy radiation layers. The laser fires from its position as a ray and destroys every radiation layer it hits. Given the radiation layers inside the wormhole and the laser firing positions, write a program that computes how many radiation layers remain after all lasers are fired.
For convenience, the laser is located at (0,0). Each radiation layer is a line segment in the first quadrant of the 2D coordinate plane. A firing position is given as (X,Y), which means the laser fires along the ray from (0,0) toward (X,Y).
The figure below shows two different laser shots at the same radiation layer.

In figure (a), the laser fired toward (2,4) hits the radiation layer and destroys it. In figure (b), the laser fired toward (3,2) misses the radiation layer and does not destroy it.
If a laser passes exactly through the start point or the end point of a radiation layer segment, the laser hits that layer. The laser is extremely thin, so you do not need to consider its thickness.
The first line contains N (1≤N≤100,000), the number of radiation layers inside the wormhole. Each of the next N lines describes the i-th radiation layer (1≤i≤N) with the coordinates of the two endpoints of its segment, x1, y1, x2, y2, separated by spaces.
The next line contains M (1≤M≤100,000), the number of laser shots. Each of the next M lines contains the firing position X, Y of the j-th laser (1≤j≤M), separated by a space.
Every coordinate in the input is an integer from 1 to 100,000, inclusive. The start point and the end point of a radiation layer segment can be the same.
Print the number of radiation layers left inside the wormhole after all lasers are fired.