[CF2289E] 掰手腕锦标赛 (The Problem from Silach)
Problem Statement
athletes numbered (strongest) to (weakest) participate in a single-elimination tournament of matches numbered to . In a match between two athletes, if their numbers differ by at least , the smaller number always wins; otherwise either athlete can win. Each match () specifies two participants (an athlete if , or the winner of match if ). Each appears once.
For each athlete , find the maximum number of matches they can participate in.
Input
First line: (). Each test case: (), followed by lines . Sum of .
Output
Output integers for each test case.
样例
2
5 1
2 5
3 4
6 7
8 1
5 2
2 5
3 4
6 7
8 1
1 3 2 1 1
1 3 3 2 1