Hide

Problem H
Goblin Garden Guards

In an unprecedented turn of events, goblins recently launched an invasion against the Nedewsian city of Mlohkcots. Goblins—small, green critters—love nothing more than to introduce additional entropy into the calm and ordered lives of ordinary people. They fear little, but one of the few things they fear is water.

The goblin invasion has now reached the royal gardens, where the goblins are busy stealing fruit, going for joyrides on the lawnmower and carving the trees into obscene shapes, and King Lrac Fatsug has decreed that this nonsense stop immediately!

Thankfully, the garden is equipped with an automated sprinkler system. Enabling the sprinklers will soak all goblins within range, forcing them to run home and dry themselves.

Serving in the royal garden guards, you have been asked to calculate how many goblins will remain in the royal garden after the sprinklers have been turned on, so that the royal gardeners can plan their next move.

Input

The input starts with one integer $1 \leq g \leq 100\ 000$, the number of goblins in the royal gardens.

Then, for each goblin follows the position of the goblin as two integers, $0 \leq x_ i \leq 10\ 000$ and $0 \leq y_ i \leq 10\ 000$. The garden is flat, square and all distances are in meters. Due to quantum interference, several goblins can occupy exactly the same spot in the garden.

Then follows one integer $1 \leq m \leq 20\, 000$, the number of sprinklers in the garden.

Finally, for each sprinkler follows the location of the sprinkler as two integers $0 \leq x_ i \leq 10\ 000$ and $0 \leq y_ i \leq 10\ 000$, and the integer radius $1 \leq r \leq 100$ of the area it covers, meaning that any goblin at a distance of at most $r$ from the point $(x_ i, y_ i)$ will be soaked by this sprinkler. There can be several sprinklers in the same location.

Output

Output the number of goblins remaining in the garden after the sprinklers have been turned on.

Sample Input 1 Sample Output 1
5
0 0
100 0
0 100
100 100
50 50
1
0 0 50
4

Please log in to submit a solution to this problem

Log in