AT_past19_d コンテスト

Description

$ N $ teams competed in a programming contest. The contest lasted $ T $ minutes. Team $ i $ solved $ A_i $ problems, and the last acceptance time was $ B_i $ . In this contest, the ranks are determined as follows: - Those who solved more problems rank higher. - Among those with the same number of solved problems, those with earlier last acceptance time rank higher. - Among those with the same number of solved problems and last acceptance time, those with a smaller team number rank higher. Let $ A' $ be the number of problems solved by the team ranked first, and $ B' $ be its last acceptance time. Find the following value $ G_i $ for each team. - $ G_i = T \times (A' - A_i) + (B_i - B') $

Input Format

The input is given from Standard Input in the following format: > $ N $ $ T $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ \vdots $ $ A_N $ $ B_N $

Output Format

Print $ N $ lines. The $ i $ -th line should contain $ G_i $ as an integer.

Explanation/Hint

### Sample Explanation 1 Six teams participated in this contest, and it lasted $ 120 $ minutes. The first-ranked team is team $ 4 $ , which solved five problems and the last acceptance time is $ 100 $ . Therefore, $ G_i $ is calculated as follows. - $ G_1 = 120 \times (5-3) + (80-100) = 220 $ - $ G_2 = 120 \times (5-4) + (90-100) = 110 $ - $ G_3 = 120 \times (5-5) + (120-100) = 20 $ - $ G_4 = 120 \times (5-5) + (100-100) = 0 $ - $ G_5 = 120 \times (5-3) + (110-100) = 250 $ - $ G_6 = 120 \times (5-4) + (70-100) = 90 $ ### Constraints - All input values are integers. - $ 1 \le N \le 1000 $ - $ 1 \le T \le 1000 $ - $ 1 \le A_i \le 1000 $ - $ 1 \le B_i \le T $