P8785 [Lanqiao Cup 2022 NOI Qualifier B] Minesweeper.

Description

Xiaoming has recently become obsessed with a game called *Minesweeper*. In one level, the task is as follows: on a 2D plane, there are $n$ mines. The $i$-th mine $(x_{i}, y_{i}, r_{i})$ means there is a mine at coordinates $(x_{i}, y_{i})$, and its blast range is a circle with radius $r_{i}$. To safely pass through this land, the player needs to clear mines. The player can launch $m$ mine-clearing rockets. Xiaoming has already planned the launch direction of each rocket. The $j$-th rocket $(x_{j}, y_{j}, r_{j})$ means this rocket will explode at $(x_{j}, y_{j})$, and its blast range is a circle with radius $r_{j}$. Any mine within its blast range will be detonated. At the same time, when a mine is detonated, any mines within its blast range will also be detonated. Now Xiaoming wants to know how many mines in total are detonated this time. You may treat both mines and mine-clearing rockets as points on the plane. Multiple mines and rockets may exist at the same point. A mine located on the boundary of a blast range will also be detonated.

Input Format

The first line contains two integers $n$ and $m$. The next $n$ lines each contain three integers $x_{i}, y_{i}, r_{i}$, describing a mine. The following $m$ lines each contain three integers $x_{j}, y_{j}, r_{j}$, describing a mine-clearing rocket.

Output Format

Output one integer, the answer.

Explanation/Hint

**[Sample Explanation]** The sample diagram is as follows. Rocket 1 covers mine 1, so mine 1 is detonated. Mine 1 also covers mine 2, so mine 2 is also detonated. ![](https://luogu.oss-cn-hangzhou.aliyuncs.com/upload/vjudge_pic/lanqiao/2022_09_29_3d61ad9326a0012c9fdag-13.jpg) **[Constraints]** For $40\%$ of the testdata: $0 \leq x, y \leq 10^{9}, 0 \leq n, m \leq 10^{3}, 1 \leq r \leq 10$. For $100\%$ of the testdata: $0 \leq x, y \leq 10^{9}, 0 \leq n, m \leq 5 \times 10^{4}, 1 \leq r \leq 10$. Lanqiao Cup 2022 Provincial Contest B Group, Problem H. Translated by ChatGPT 5