**Problem
**

D(Z_{P},+,*) is an algebraic system, where

- Z
_{P}= {a_{0}+ a_{1}x + a_{2}x^{2}+ ... a_{n}x^{n}}, where n is a non-negative integer and a_{i}(0 <= i <= n) is an integer, 0 <= a_{i}< P, P is a prime number. - If A, B ¡Ê Z
_{P}£¬A = a_{0}+ a_{1}x + a_{2}x^{2}+ ... a_{m}x^{m}, B = b_{0}+ b_{1}x + b_{2}x^{2}+ ... b_{n}x^{n}; then

C = A + B = c_{0}+ c_{1}x + c_{2}x^{2}+ ... c_{r}x^{r}, where r = max(m, n), c_{i}= (a_{i}+b_{i}) mod P (0 <= i <= r);

D = A * B = d_{0}+ d_{1}x + d_{2}x^{2}+ ... d_{m+n}x^{m+n}, where d_{i}= (a_{0}b_{i}+ a_{1}b_{i-1}+ ... + a_{i}b_{0}) mod P.

Suppose A, C ¡Ê Z_{P}, if there exists a B ¡Ê Z_{P} such that C = A * B, then we say A is a factor of C, denoted as A | C. If A | C, A | D, then A is a common factor of C and D. Furthermore, if A is a common factor of C, D and every common factor of C and D is also a factor of A, then A is said to be the greatest common factor of C and D.

Given C, D ¡Ê Z_{P}, your task is to get their greatest common factor.

**Input **

The first line contains an integer T(T <= 100), which is the number of test cases. Each case will conform to the following form:

P m n

c_{0} c_{1} ... c_{m}

d_{0} d_{1} ... d_{n}

P is a prime number in the range of [2, 10000); 1 <= m, n <= 100; c_{m},d_{n} > 0.

**Output**

For each test case, output coefficients of the greatest common factor in a single line in the following form:

a_{0} a_{1} ... a_{k}

If the answer is not unique, you should print the one with a_{k} = 1.

**Sample Input**

3

23 2 4

3 17 20

15 3 19 20 15

23 1 1

0 12

0 9

7 1 2

1 1

0 1 1

**Sample Output**

22 2 1

0 1

1 1