Welcome to ZOJ
Information
Problems
Runs
Statistics
Ranklist
Clarification
52 - Andrew Stankevich's Contest, Warmup - 1004
Equations System

Time Limit: 10 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


Submit    Status