Elimination Round, Problem F

Given positive a_i and d, decide whether nonzero x_i exist with sum a_i x_i = d, and if so build the unique sequence defined by the greedy rule minimizing each |D_i|.

Hard8Number theoryGreedyMathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Gnome Paul is competing in the elimination round of the Gnome Math Cup. Problem F reads as follows.

You are given nn positive integers a1,a2,,ana_1, a_2, \ldots, a_n and a positive integer dd. Find nonzero integers x1,x2,,xnx_1, x_2, \ldots, x_n with xi107|x_i| \le 10^7 such that

a1x1+a2x2++anxn=d.a_1 x_1 + a_2 x_2 + \cdots + a_n x_n = d.

Gnomes dislike big numbers, so every aia_i and dd is at most 10610^6, and no xix_i may be 00.

Many sequences can satisfy the equation, so exactly one of them counts as the answer. Set sn+1=0s_{n+1} = 0 and, for i=n,n1,,1i = n, n-1, \ldots, 1, set si=gcd(ai,si+1)s_i = \gcd(a_i, s_{i+1}), so sis_i is the greatest common divisor of ai,ai+1,,ana_i, a_{i+1}, \ldots, a_n. A required sequence exists if and only if s1s_1 divides dd. When it exists, build it from left to right. Put D0=dD_0 = d, and for i=1,2,,n1i = 1, 2, \ldots, n-1 pick xix_i this way.

  1. xix_i is not 00, and Di=Di1aixiD_i = D_{i-1} - a_i x_i is not 00 and is a multiple of si+1s_{i+1}.
  2. Among all such xix_i, take one that makes Di|D_i| as small as possible.
  3. If two of them give the same Di|D_i|, take the smaller xix_i.

The last value is xn=Dn1/anx_n = D_{n-1} / a_n. For n=1n = 1 nothing is picked and x1=d/a1x_1 = d / a_1. Every value this rule produces satisfies xi107|x_i| \le 10^7.

Input

The first line contains one integer tt, the number of tests (1t1051 \le t \le 10^5). The tests follow.

The first line of each test contains two integers nn and dd (1n1051 \le n \le 10^5, 1d1061 \le d \le 10^6). The second line contains nn integers aia_i (1ai1061 \le a_i \le 10^6). The sum of nn over all tests does not exceed 10510^5.

Output

Print the answer for each test. If the required sequence exists, print YES on one line, then print x1,x2,,xnx_1, x_2, \ldots, x_n separated by single spaces on the next line. Only the sequence defined above is accepted. If there is no such sequence, print NO as the only line for that test.