Олимпиадный тренинг

Задача 38343. Round Equality


Given a valid equality of the form a1+a2+…+aN=b1+b2+…bM, where a1,a2,…,aN, b1,b2,…,bM – some real (not necessarily integer) numbers. Required to "round up" this is equality, i.e. get a new correct equality c1+c2+…+cN=d1+d2+…+dM, where c1,c2,…,cN< /sub>,d1,d2,…,dM — integers, and at the same time c1 is obtained by rounding the number a1 up or down to an integer (for example, the number 1.7 can be rounded up to either 1 or 2) , c2 obtained by rounding a2, …, cN – rounding aN, d1 – rounding b1, …, dM – rounding bM. If any of the numbers in the original equality was an integer, it should remain unchanged.

Input
The input file is given first the number N, then N numbers a1, a2, …, aN, then the number M, then the numbers b1, b2, …, bM. Each number is given on a separate line. M and N – natural numbers not exceeding 1000. Other numbers — real, each of them does not exceed 1000 in absolute value and contains no more than 6 digits after the decimal point. Here a1+a2+…+aN=b1+b2 +…bM.

Imprint
If "round up" equality is possible, then output the numbers c1,c2,…,cN, and then the numbers d 1,d2,…,dM. All numbers must be integers and printed without a decimal point. Numbers must be separated by spaces or newlines. If there are several solutions, print any of them.

If it is impossible to round the original equality to a true integer equality, print a single number 0.
Examples
# Input Output Explanation
1 3
0.15
-3.000
2.7
1
-0.15
1
-3
2
0
Note that –3 can only be rounded to –3, while 0.15 can be rounded to either 0 or 1, 2.7 – up to 2 or up to 3, –0.15 – up to –1 or up to 0. The given solution is not the only one: the following rounding is also correct, for example: 1+(–3)+2=0
 
2 2
1.7
2.5
3
1
2.000
1.20
2
2
1
2
1
The given solution 1+3=1+2+1 is not the only one. The correct answers are also 2+2=1+2+1 and 2+3=1+2+2.
 
3 1
0.5
1
0.5
0
0
Here, both 1=1 and 0=0 are correct.