DPEQN  Congruence Equation
English  Vietnamese 
Given a congruence equation:
a_{1}x_{1} + ... a_{2}x_{2} + ... + a_{n}x_{n} = b (mod m)
In which, a_{1}, a_{2}, ..., a_{n}, b and m are positive integer constants; x_{1}, x_{2}, ..., x_{n} are unknowns.
Find a solution for this equation, or show that the equation has no solution.
Input
First line: number of test cases. Each test case has the following form:
 Line 1: n (1 ≤ n ≤ 100)
 Line 2: n integers a_{1}, a_{2}, ..., a_{n} (1 ≤ a_{i} ≤ 10^{8})
 Line 3: b, m (1 ≤ b, m ≤ 10^{8})
Each test case is separated by a blank line.
Output
For each test case, if the equation has no solution, print "NO". Otherwise, print n integers x_{1}, x_{2}, ..., x_{n} (0 ≤ x_{i} < m) that is one solution to the equation.
Example
Input 2 2 4 6 6 10 2 4 6 3 8 Output 1 2 NO
hide comments
Anshu Avinash:
20110924 11:48:13
Are all possible solutions accepted? 

Tasnim Imran Sunny:
20100421 18:33:06
.. Last edit: 20100421 18:38:38 
Added by:  Duc 
Date:  20081018 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  © VNOI 