Under construction

Still being built. Things may change

Yet Another Coin Problem

Time limit2sMemory limit1024 MB

Summary
Given N coin types with counts and values, decide whether some choice of coins sums to exactly X, and print the number of each coin type used if so.
Level

Hard8 of 10

Topics
Dynamic programming, Number theory
Solved
No attempts yet

Problem

There are NN kinds of coins. The ii-th kind has CiC_i coins, and each coin is worth ViV_i won. (1≤i≤N)(1 \le i \le N) Can you choose some coins so that their values sum to exactly XX won? If it is possible, print one way to do it.

Input

The first line contains the number of test cases TT. (1≤T≤100)(1 \le T \le 100)

The first line of each test case contains NN and XX, separated by a space. (1≤N≤50;1≤X≤1018)(1 \le N \le 50; 1 \le X \le 10^{18})

Each of the next NN lines contains CiC_i and ViV_i, separated by a space. Within one test case, all ViV_i are distinct. (1≤Ci≤1012;1≤Vi≤500 000)(1 \le C_i \le 10^{12}; 1 \le V_i \le 500\,000)

The sum of NN over all test cases does not exceed 500500, and the sum of all ViV_i does not exceed 500 000500\,000.

Output

For each test case, print YES if you can choose coins so that their values sum to exactly XX won, and NO otherwise. If you print YES, print a second line with NN integers A1,⋯ ,ANA_1, \cdots, A_N separated by spaces. They must satisfy the following conditions.

  • 0≤Ai≤Ci0 \le A_i \le C_i (1≤i≤N)(1 \le i \le N)
  • A1V1+A2V2+⋯+ANVN=XA_1V_1 + A_2V_2 + \cdots + A_NV_N = X

Examples1

  1. Example 1

    Input
    2
    4 361
    3 1
    4 5
    5 10
    6 50
    4 364
    3 1
    4 5
    5 10
    6 50
    
    Expected output
    YES
    1 2 5 6
    NO