Wi-Fi Tower Upgrade

No attempts yetTime limit5sMemory limit512 MB

Problem

You are given a network of wireless towers. Each tower has a range and sends data to another tower whenever the distance to it is at most the sending tower's range.

Every tower currently runs the old protocol A. A new protocol B with better bandwidth is available, and you want to upgrade some of the towers to B.

One restriction applies. If a tower TT runs the new protocol B, every tower within TT's range must run B as well, so that they understand the data TT sends. The reverse is not required. A tower running the new protocol B may still receive data from a tower running the old protocol A.

An upgrade brings a benefit and also costs money to install. Each tower therefore carries one score, the value of upgrading it, and that score is positive or negative. Choose the set of towers to upgrade so that the total score of the upgraded towers is as large as possible. You may upgrade no tower at all, in which case the total is 0.

Input

The first line contains the number of test cases TT.

Each test case starts with a line containing the number of towers nn. Each of the next nn lines contains four integers xx, yy, rr, ss separated by spaces: a tower at coordinates (x,y)(x, y) with range rr and score ss, the value of upgrading it to the new protocol.

Distances between towers are Euclidean. Tower AA sends data to tower BB when the distance from AA to BB is at most AA's range.

Limits

  • 1T551 \le T \le 55
  • 1n5001 \le n \le 500
  • 10000x,y10000-10000 \le x, y \le 10000
  • 1r200001 \le r \le 20000
  • 1000s1000-1000 \le s \le 1000
  • No two towers share the same coordinates.

Output

For each test case, print one line in this format:

Case #X: score

Here XX is the test case number starting from 1, and score is the total score of the best choice.