Target#2974

Target

1 second
64 megabytes
Very easy

A shooting target consists of a diagram with concentric circles: one central circle and surrounding rings. The central circle is labeled with the number . The first ring surrounding the center is labeled , the next one , and so on down to the ring labeled . In competitions, a shooter fires a number of shots at the target, and the points they earn are calculated based on where the bullets land. If a bullet hits the central circle labeled , the shooter earns points for that shot. If a bullet lands on a ring labeled , the shooter earns points. If a bullet strikes the boundary between two rings, the shooter receives the higher of the two possible scores. For example, if a bullet hits the boundary between the ring labeled and the ring labeled , the shooter receives points. If a bullet lands outside the outermost ring labeled (often referred to as "in the milk"), the shooter scores points for that shot. The shooter's total score is the sum of points from all shots.

You will be provided with a description of the target and the shots fired. Your task is to compute the total score achieved by the shooter.

Input

Assume the target is represented on a coordinate plane with its center at the origin, and shots are given as points on this plane.

The first line of the input contains positive integers separated by spaces: R_{10}, D_9, D_8, D_7, \dots, D_1. The first integer R_{10} is the radius of the inner circle labeled . The second integer D_9 is the width of the ring labeled , D_8 is the width of the ring labeled , and so on. All numbers are no greater than . Note that the widths of the rings can vary, that is, D_9, D_8, \dots, D_1 can be different.

The second line of input contains a single integer (0 \leq N \leq 1000) — the number of shots fired.

Each of the following lines contains integers X_i, Y_i, separated by a space — the coordinates of the shots (each shot is a point on the plane). Absolute values of the coordinates do not exceed .

Output

For each input file, output a single integer — the total points scored by the shooter according to the rules described above.

Examples

Example 1

Loading
Loading