In a system as crowded as the solar system, nobody wants to compute the gravity between two objects that sit very far apart, and the value comes out so small that the work is wasted anyway. So only pairs of objects closer than k are worth looking at.
Given n points in space, how many pairs of points are at a distance smaller than k?
The input holds several test cases.
The first line of each test case has the number of points n and the largest allowed distance k. (2≤n≤100,000, 1≤k≤109)
Each of the next n lines has three integers x, y, z, the coordinates of one point. (−109≤x,y,z≤109)
No point is given twice within one test case, and at most 100,000 pairs of points are at a distance of k or less.
The last line of the input has two zeros, and that line is not a test case.
For each test case print the number of point pairs whose distance is smaller than k, one count per line.