Salary Increase

Time limit1sMemory limit128 MB

Problem

Yeonjong is the founder of the venture company "Bongssi". At first, he was the company's only worker. As the business grew, he started hiring employees one by one. There are now N employees other than Yeonjong.

The company uses numbers instead of employee names. Yeonjong's number is 0, and the employees are numbered from 1 to N in the order they are hired.

When a new employee joins, they become the subordinate of one existing employee. Yeonjong sets the new employee's first salary after checking their ability.

If the new employee's salary is greater than the current salary of their direct boss, that boss's salary is raised to match the new employee's salary. If this makes the boss's salary greater than their own boss's salary, that upper boss's salary is also raised to the same new employee salary. This continues upward until every employee has a salary less than or equal to their direct boss's salary.

Given the hiring order, each new employee's first salary, and the number of their direct boss, print how many existing employees receive a salary increase after each hire.

Input

The first line contains the number of employees N. (1 <= N <= 300,000)

The second line contains Yeonjong's initial salary.

Each of the next N lines contains I and B in hiring order. I is the new employee's first salary, and B is the number of their direct boss.

Every salary is between 1 and 10^9, inclusive.

Output

For each hire, print the number of existing employees whose salaries are increased. Print one number per line, for a total of N lines.