Welcome to ZOJ Problem Sets Information Select Problem Runs Ranklist ZOJ Problem Set - 2707
Equations System

Time Limit: 5 Seconds      Memory Limit: 32768 KB      Special Judge

In the eighth grade of the high school students learn how to solve systems of linear equations. This time you have to solve the system of two linear equations with two unknowns in polynomials over F2 . That is, both coefficients and variables are polynomials with coefficients from F2 = {0, 1} , operations in this field are carried out modulo 2.

Given polynomials a1(t) , b1(t) , c1(t) , a2(t) , b2(t) , and c2(t) , find polynomials x(t) and y(t) , such that:
 { a1(t)x(t)+b1(t)y(t) = c1(t) a2(t)x(t)+b2(t)y(t) = c2(t)

Input

There are mutiple cases in the input file.

Six lines of each case describe polynomials a1(t) , b1(t) , c1(t) , a2(t) , b2(t) , and c2(t) in this order.

Each polynomial is specified with its degree k followed by k+1 coefficients, starting from the leading one. Each coefficient is either 0 , or 1 . Constant zero polynomial has the degree of -1 in this problem. Degrees of the polynomials do not exceed 100 .

There is an empty line after each case.

Output

Output two polynomials, one on a line --- x(t) and y(t) . Use the same format as in input. If there is no solution to the system of the equations, output “No solution” instead. If there are several solutions, output any one with the degree not exceeding 1000 (it can be proved that if there is some solution, there is such one).

There should be am empty line after each case.

Sample Input

```1 1 0
0 1
3 1 1 0 0
1 1 1
1 1 0
1 1 1

1 1 0
1 1 1
0 1
1 1 0
1 1 1
0 1

1 1 0
1 1 1
0 1
1 1 0
1 1 1
-1

```

Sample Output

```2 1 0 1
2 1 1 0

0 1
0 1

No solution

```

Source: Andrew Stankevich's Contest #10
Submit    Status