|
A polynomial in <tt>x</tt> of degree <b>D</b> can be written as: |
|
<pre> |
|
a<sub>D</sub>x<sup>D</sup> + a<sub>D-1</sub>x<sup>D-1</sup> + ... + a<sub>1</sub>x<sup>1</sup> + a<sub>0</sub> |
|
</pre> |
|
In some cases, a polynomial of degree <tt><b>D</b></tt> can also be written as the product of two polynomials of degrees <tt><b>D<sub>1</sub></b></tt> and <tt><b>D<sub>2</sub></b></tt>, where <tt><b>D = D<sub>1</sub> + D<sub>2</sub></b></tt>. For instance, |
|
<pre>4 x<sup>2</sup> + 11 x <sup>1</sup> + 6 = (4 x<sup>1</sup> + 3) * (1 x<sup>1</sup> + 2)</pre> |
|
In this problem, you will be given two polynomials, denoted <tt><b>F</b></tt> and <tt><b>G</b></tt>. Your task is to find a polynomial <tt><b>H</b></tt> such that <tt><b>G</b> * <b>H</b> = <b>F</b></tt>, and each <tt>a<sub>i</sub></tt> is an integer. |
|
|
|
|
|
<h2>Input</h2> |
|
You should first read an integer <tt><b>N ≤ 60</b></tt>, the number of test cases. Each test case will start by describing <tt><b>F</b></tt> and then describe <tt><b>G</b></tt>. Each polynomial will start with its degree <tt>0 ≤ <b>D</b> ≤ 20</tt>, which will be followed by <tt><b>D</b>+1</tt> integers, denoting <tt>a<sub>0</sub>, a<sub>1</sub>, ... , a<sub>D</sub></tt>, where <tt>-10000 ≤ a<sub>i</sub> ≤ 10000</tt>. Each polynomial will have a non-zero coefficient for it's highest order term. |
|
|
|
<h2>Output</h2> |
|
For each test case, output a single line describing <tt><b>H</b></tt>. If <tt><b>H</b></tt> has degree <tt><b>D<sub>H</sub></b></tt>, you should output a line containing <tt><b>D<sub>H</sub></b> + 1</tt> integers, starting with <tt>a<sub>0</sub></tt> for <tt><b>H</b></tt>. If no <tt><b>H</b></tt> exists such that <tt><b>G*H=F</b></tt>, you should output "no solution". |
|
|