Adding Continued Fractions#5969

Adding Continued Fractions

1 second
64 megabytes
Medium

Two finite continued fractions are provided.

Your task is to determine a finite continued fraction whose value equals the sum of the values of the given fractions.

Input

The first line of the input specifies the first fraction in the format [a_0, a_1, \ldots, a_{n-1}] where 1 \leq n \leq 100, -100 \leq a_0 \leq 100, and 1 \leq a_i \leq 100 for i > 0. The second line provides the second fraction in the same format.

Output

Output a single line containing the continued fraction that represents the sum of the given fractions, formatted in the same way.

Examples

Example 1

Loading
Loading