Darts Game
Time limit2sMemory limit512 MB
Given N scored darts, find the maximum total score inside a square of side L centered at the origin, where the square may be rotated to any angle.
Problem
Darts is a fun game. The game in this problem is a bit different.
The board can be considered as an infinite 2-dimensional plane, and you have already shot darts. Each dart is at a point and has a score . Several darts can be at the exact same location, even with different scores. A score can be negative.
After shooting all the darts, you must draw a square on the plane. The side length of the square must be , and the point must be exactly at the center of the square. You can rotate the square in any direction you want. You can rotate it only once, before considering any darts.
You get the score of every dart that is inside the square or on its boundary. Given the location and score of each dart and the value of , find the maximum score you can get. The square is allowed to contain no darts.
Input
Your program will be tested on one or more test cases. The first line contains an integer (), the number of test cases.
Each test case starts with a line containing two integers () and (), separated by a space. Then lines follow. Each line contains three integers , , , separated by spaces. This means there is a dart at that gives score . All values satisfy .
Output
For each test case, print one line with the maximum score you can get by drawing the square.
Hint

The figure shows the first test case. No placement of the square includes the point with score 100, but if you rotate the square slightly, it no longer includes the point with score -101.