Hide

Problem K
Darts

Consider a game in which darts are thrown at a board. The board is formed by $10$ circles with radii $20$, $40$, $60$, $80$, $100$, $120$, $140$, $160$, $180$, and $200$ (measured in millimeters), centered at the origin. Each throw is evaluated depending on where the dart hits the board. The score is $p$ points ($p \in \{ 1, 2, \ldots , 10\} $) if the smallest circle enclosing or passing through the hit point is the one with radius $20 \cdot (11 - p)$. No points are awarded for a throw that misses the largest circle. Your task is to compute the total score of a series of $n$ throws.

Input

The first line of the input contains the number of test cases $T$, where $1 \le T \le 10\, 000$. The descriptions of the test cases follow:

Each test case starts with a line containing the number of throws $n$ ($1 \leq n \leq 10^6$). Each of the next $n$ lines contains two integers $x$ and $y$ ($-200 \leq x, y \leq 200$) separated by a space—the coordinates of the point hit by a throw. The sum of $n$ across all $T$ test cases is at most $2^{21}$.

Output

Print the answers to the test cases in the order in which they appear in the input. For each test case print a single line containing one integer—the sum of the scores of all $n$ throws.

Sample Input 1 Sample Output 1
1
5
32 -39
71 89
-60 80
0 0
196 89
29

Please log in to submit a solution to this problem

Log in