Relay Signal

Count boats reachable within one relay hop from boat 1, where visibility means the connecting segment never enters the convex island interior; every coordinate is a lattice point.

Hard8GeometrySortingBinary searchTwo pointersNo attempts yetTime limit2sMemory limit512 MB

Problem

People live on an island. Most of them fish for a living, so NN households on the island own a fishing boat. In the afternoon, when everyone heads out to work, all NN boats leave the island and float on the sea, and each boat can be drawn as a single point on the coordinate plane. The island is a convex polygon with MM vertices. Every boat and every vertex of the island sits on a lattice point. The picture below is one example of an island and its boats.

Example layout of the island and the boats

(The orange convex polygon in the middle is the island, and the numbered blue points are the fishing boats.)

Every boat carries a radio, and two boats exchange messages when nothing blocks the way between them. To be exact, two boats exchange messages when the segment joining them does not meet the interior of the island. A segment that only touches a vertex or an edge of the convex polygon does not count as meeting the interior.

When boat 11 runs into trouble, it sends a rescue signal to every boat its signal reaches. Each boat that receives the rescue signal then sends a relay signal to every boat its own signal reaches, telling them that boat 11 is in trouble. A boat that receives a relay signal does not pass the signal on.

You know the MM vertices of the island and the positions of the NN boats numbered 11 to NN. Boat 11 is in trouble. Count the boats that receive at least one of the rescue signal sent by boat 11 and the relay signals sent by the boats that received it. Boat 11 is not counted.

Input

The first line contains the number of boats NN (1N1000001 \le N \le 100000).

Each of the next NN lines describes one boat. The ii-th of these lines contains the xx coordinate and the yy coordinate of boat ii, separated by a space.

The next line contains the number of vertices of the island MM (3M1000003 \le M \le 100000).

Each of the next MM lines describes one vertex. The ii-th of these lines contains the xx coordinate and the yy coordinate of the ii-th vertex of the island, separated by a space.

The island is a convex polygon and its vertices are given in counter-clockwise order. Two adjacent edges never have the same slope.

Every coordinate is an integer between 109-10^9 and 10910^9.

All boats have distinct coordinates, and no boat lies inside the island or on its boundary.

Output

Print the number of boats that receive the rescue signal or a relay signal when boat 11 is in trouble.