Nearby Gravitation

No attempts yetTime limit5sMemory limit128 MB

Problem

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 kk are worth looking at.

Given nn points in space, how many pairs of points are at a distance smaller than kk?

Input

The input holds several test cases.

The first line of each test case has the number of points nn and the largest allowed distance kk. (2n100,0002 \le n \le 100{,}000, 1k1091 \le k \le 10^9)

Each of the next nn lines has three integers xx, yy, zz, the coordinates of one point. (109x,y,z109-10^9 \le x, y, z \le 10^9)

No point is given twice within one test case, and at most 100,000100{,}000 pairs of points are at a distance of kk or less.

The last line of the input has two zeros, and that line is not a test case.

Output

For each test case print the number of point pairs whose distance is smaller than kk, one count per line.