Target
A shooting target consists of a diagram with 10 concentric circles, including one central circle and 9 surrounding rings. The central circle is labeled with the number 10. The first ring surrounding the center is labeled 9, the next one 8, continuing in this manner down to the ring labeled 1. In competitions, a shooter fires a series 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 10, the shooter earns 10 points for that shot. If a bullet lands on a ring labeled K, the shooter earns K points. If a bullet strikes the boundary between two rings, the shooter receives the higher of the two possible scores. For instance, if a bullet hits the boundary between the ring labeled 5 and the ring labeled 4, the shooter receives 5 points. If a bullet lands outside the outermost ring labeled 1 (often referred to as "in the milk"), the shooter scores 0 points for that shot. The total score is the sum of the points from all shots.
You will be provided with a description of the target and the shots fired by the shooter. Your task is to compute the total score achieved by the shooter.
Input
The target is represented on a coordinate plane with its center at the origin, and the shots are given as points on this plane.
The first line of the input file contains 10 positive integers separated by spaces: R_10, D_9, D_8, D_7, ..., D_1. The first integer, R_10, is the radius of the inner circle labeled 10. The second integer, D_9, is the width of the ring labeled 9, D_8 is the width of the ring labeled 8, and so forth. All these numbers are no greater than 100000. Note that the widths of the rings can vary, meaning D_9, D_8, D_7, ..., D_1 can differ from each other.
The second line of the input file contains a single integer N (0 ≤ N ≤ 1000) - the number of shots fired by the shooter.
Each of the following N lines in the input file contains 2 integers X_i, Y_i, separated by a space - these are the coordinates of each shot (each shot is a point on the plane). The coordinates do not exceed 1000000 in absolute value.
Output
For each input file, output a single integer in the output text file - the total points scored by the shooter according to the rules described above.