#K331. Circles Containing a Point

    ID: 25012 Type: Default 1000ms 256MiB

Circles Containing a Point

Circles Containing a Point

You are given several datasets. Each dataset consists of a reference point and several circles. For each dataset, your task is to determine how many circles contain the given point.

A point \((p_x, p_y)\) is considered to be inside a circle if the Euclidean distance between \((p_x, p_y)\) and the center \((c_x, c_y)\) is less than or equal to the radius \(r\). The distance is calculated using the formula: \(\sqrt{(p_x-c_x)^2 + (p_y-c_y)^2}\).

Note that a point lying exactly on the boundary of a circle is considered to be inside the circle.

inputFormat

The first line of input contains an integer \(T\) representing the number of datasets. For each dataset, the input is structured as follows:

  • A line containing two integers \(p_x\) and \(p_y\), the coordinates of the point.
  • A line containing an integer \(n\), the number of circles.
  • \(n\) lines each containing three integers \(c_x\), \(c_y\), and \(r\) representing the center coordinates and radius of a circle.

All values are separated by spaces.

outputFormat

For each dataset, output a single integer on a new line, representing the count of circles that contain the given point.

## sample
2
5 5
3
1 1 3
4 4 2
6 6 1
7 9
2
8 10 5
7 7 2
1

2

</p>