Company: InMobi_3rdaug
Difficulty: medium
Temporal Anomalies The temporal fabric of the universe is analyzed as a series of events in a 3D continuum with X , Y and Z coordinates. You are given N anomalies. The i -th anomaly occurs at (X_i, Y_i, Z_i) and carries a severity S_i . Anomaly i dominates anomaly j when all three of X_i >= X_j Y_i >= Y_j Z_i >= Z_j hold at once. The inequalities are non-strict, so every anomaly dominates itself, and if two anomalies sit at exactly the same coordinates then each dominates the other. The Domination Score of anomaly i is the sum of the severities S_j of every anomaly j that i dominates, itself included. Report the Domination Score of each anomaly. 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 and S_i , separated by spaces. Output Format Print N lines. The i -th line holds the Domination Score of the i -th anomaly, in the order the anomalies were given in the input . Constraints 1 <= N <= 1500 1 <