Subspecies

No attempts yetTime limit10sMemory limit128 MB

Problem

A university is studying a newly discovered species of annelid (a segmented worm) whose body has a very large number of segments. The research team has earned the right to name the species, and they may also split the discovered specimens into several subspecies.

For two specimens to belong to the same subspecies, their length, weight, and number of segments must not differ by too much. Specifically, the length difference may be at most DD, the weight difference at most WW, and the segment-count difference at most SS.

For each specimen oo, determine how many other specimens pp could belong to the same subspecies as oo.

Input

The first line contains the number of test cases ZZ (Z=1Z = 1). Each test case follows.

The first line of a test case contains the number of specimens NN (1N800001 \le N \le 80000). The next line contains three integers DD, WW, SS (1D,W,S1091 \le D, W, S \le 10^9).

Each of the next NN lines contains the length did_i, weight wiw_i, and segment count sis_i of one specimen (1di,wi,si1091 \le d_i, w_i, s_i \le 10^9). Because the measurements were extremely precise, the lengths of any two distinct specimens are all different, and so are the weights.

Output

Print NN non-negative integers on a single line, separated by spaces. The ii-th integer is the number of specimens, other than specimen ii itself, that could belong to the same subspecies as specimen ii.

Hint

In the example, specimens 1 and 3 have lengths that differ by 22, which exceeds D=1D = 1, so they can never be placed in the same subspecies. Every other pair can.