#P7849. Fluctuation Limit(无SPJ)

Fluctuation Limit(无SPJ)

Fluctuation Limit

Problem Description

It is preferrable to read the pdf statment. Cuber QQ has signed up for a gambling game, that challenges him to predict the stock price of Quber CC Limited, for the next following nn days. He shall make his prediction by filling a table with nn intervals, the ii-th of which is the predicted interval [li,ri][l_i, r_i] at the ii-th day. If all nn prices lie in the corresponding interval, Cuber QQ will win 1 million dollars. Otherwise, he will not earn a single penny. As is well known, the stock price has a fluctuation limit. For simplicity, we assume the limit up and the limit down are both kk, which is an integer. That means, if the stock price at the ii-th day is xx, the price at the i+1i+1-th day is at most x+kx+k and at least xkx-k. Cuber QQ wants to know whether it is possible to manipulate the stock price, without breaking the limitation above of course, so that he can have the 11 million dollars. Since his table has already been submitted, he cannot modify his predicted intervals any more. It has to be done secretly behind the scenes, and smartly cover it up so that no one will notice.

Input

The input starts with an integer TT (1T1051 \le T \le 10^5), denoting the number of test cases. For each test case, the first line contains two space-separated integers nn and kk (2n1052 \le n \le 10^5, 0k1090 \le k \le 10^9), where nn is the number of days and kk is the fluctuation limit. The ii-th line of the next nn lines contains two space-separated integers lil_i and rir_i (0liri1090 \le l_i \le r_i \le 10^9), which is Cuber QQ's predicted interval in the ii-th day. A prediction is believed to be correct if the stock price ii-th day lies between lil_i and rir_i, inclusive. It is guaranteed that the sum of all nn does not exceed 10610^6.

Output

For each test case, first output a single line YES or NO , that states whether Cuber QQ will win the 1 million price. If YES , in the next line, output a possible price series, a1,a2,,ana_1, a_2, \ldots, a_n, where liairil_i \le a_i \le r_i (1in1 \le i \le n) and aiai+1k|a_i - a_{i+1}| \le k (1in11 \le i \le n - 1). The integers should be separated with space.

Sample Input

2
3 1
1 6
2 5
3 6
2 3
1 5
10 50

Sample Output

YES
2 3 3
NO

Source

2020 Multi-University Training Contest 8