Saint John Festival

Count how many small lantern points fall inside or on the boundary of the convex hull of the large lantern points.

Medium6GeometrySortingBinary searchNo attempts yetTime limit1sMemory limit256 MB

Problem

The Festa de São João in Porto is one of the busiest street festivals in Europe. It peaks on the night of 23 June into the morning of 24 June, with dancing from Ribeira to Foz all night long.

People celebrate with friends, relatives and neighbours, and with whoever else is out on the street. They carry coloured plastic hammers, huge garlic flowers and bunches of lemongrass, and they tap passers by on the head with them. Fireworks, grilled sardines, barbecues, bonfires and potted basil fill the streets, and sky lanterns launched from every corner cover the sky.

A sky lantern is made of thin paper and cannot be released before it fills with hot air. A sudden gust of wind sometimes burns one out on the ground or on the way up. Someone who launches a lantern successfully follows it with their eyes for as long as they can still tell it apart in the sky.

Picture thousands of people in the city park preparing their lanterns for a simultaneous release. The large lanterns among them mark positions that can be recognised in the sky afterwards.

You are given the positions of the large lanterns and the positions of the small ones. Count the small lanterns that lie in the interior or on the boundary of some triangle formed by any three of the large lanterns.

Input

The first line has an integer LL, the number of large lanterns in the sky at the observation instant. Each of the following LL lines has the coordinates xx and yy of one large lantern, separated by a space. The next line has an integer SS, the number of small lanterns, and the following SS lines give the coordinates of the small lanterns in the same format. Height does not matter here.

All given points are distinct, and among the large lanterns there are at least three points that are not collinear.

Output

Print on a single line the number of small lanterns that lie in the interior or on the boundary of some triangle formed by any three of the large lanterns.

Constraints

  • 3L100003 \le L \le 10000 (number of large lanterns)
  • 1S500001 \le S \le 50000 (number of small lanterns)
  • 0x,y2300 \le x, y \le 2^{30} (range of the coordinates)
  • All coordinates are integers.

Hint