403383: GYM101147 I On the way to the park

Memory Limit:64 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. On the way to the parktime limit per test10.0 smemory limit per test64 megabytesinputwalk.inoutputstandard output

Engineers around the world share a lot of common characteristics. For example, they're all smart, cool and extremely lazy!

Asem is a computer engineer, so he is very lazy. He doesn't leave the house for weeks. Not even for a shisha with his best friends.

One day his mother insisted that he goes to the park to get some fresh air. Asem is a lazy but a very practical person. He decided to use the time spent on the way to the park to test his new device for detecting wireless networks in the city. The device is as much advanced as it's weird. It detects a network if the coverage area of the network is entirely inside the coverage area of the device. Both the coverage area of the wireless networks and Asem's device are circular shaped.

The path between Asem's house and the park is a straight line and when Asem turn on the device, it display one integer on its screen, the sum of the radiuses of the detected networks.

Given the coordinates of the center of the networks coverage area and their radiuses, what is the maximum number that could be displayed on the screen knowing that Asem can test the device anywhere in the street?

Input

The first line of the input will contain T the number of test cases.

Each test case starts with two integers on a single line (0 < N ≤ 105), the number of wireless networks, (0 < M ≤ 109), the radius of the coverage area of Asem's device.

Then N lines follow, each describes a wireless network and contains three integers ( - 109 ≤ xi ≤ 109), the X coordinate of the center of the i'th network coverage area,( - 109 ≤ y ≤ 109), the Y coordinate of the center of the i'th network coverage area, (1 ≤ ri ≤ 109), the radius of the i'th network coverage area. Where the street is the X-axis here and Asem can test the device anywhere on it.

Output

For each test case print one integer. The maximum number that could be displayed on the screen.

ExampleInput
2
3 5
0 0 1
4 0 2
10 0 1
4 3
0 1 1
0 -3 1
10 1 1
0 -4 2
Output
3
1
Note

Large I/O files. Please consider using fast input/output methods.

The figure shows a possible solution for the first sample.

加入题单

上一题 下一题 算法标签: