Company: InMobi
Difficulty: medium
The temporal fabric of the universe can be analyzed as a series of events happening in a 3D continuum with X, Y, and Z coordinates. You are given a set of N anomalies. The i-th anomaly occurs at coordinates (X i , Y i , Z i ) and possesses a severity rating S i . We say that anomaly i dominates anomaly j if and only if: X i ≥ X j and Y i ≥ Y j and Z i ≥ Z j For each anomaly i, its Domination Score is the sum of the severities S j of all anomalies j that it dominates (including itself). Calculate the Domination Score for every anomaly. Note that two anomalies may share the exact same coordinates; in that case each dominates the other (the inequalities are non-strict). Input Format The first line contains a single integer N. Each of the next N lines contains four integers X i , Y i , Z i , S i . Constraints 1 ≤ N ≤ 10 5 1 ≤ X i , Y i , Z i ≤ 10 5 1 ≤ S i ≤ 10 4 Output Format Output N lines. The i-th line should contain the Domination Score of the i-th anomaly (