202. Mixed Fractions

I'm a slow walker, but I never walk backwards.

Task Description

Write a program to calculate addition, subtraction, multiplication, and division for two mixed fractions. You will be given two mixed fractions -- $a \dfrac{b}{c}$ and $e \dfrac{f}{g}$. For example, if $a = 1$, $b = 3$, and $c = 4$, then you have 1.75. You can also represent negative number by a negative $a$, so if $a = -1$, $b = 3$, and $c = 4$, then the result is -1.75. For simplicity we assume that $a$ and $e$ are always non-zero, $b$ and $f$ are always non-negative, and $c$ and $g$ are always positive. Also, $b$ and $c$ have to be simplified. For example, you cannot have $a = 1$, $b = 6$, and $c = 8$. Also when $b$ or $f$ is 0, $c$ and $g$ must be 1. We will be given an extra number $d$ as the operator. If $d$ is 0, 1, 2, 3, then the operation is addition, subtraction, multiplication, and division, respectively. Now given $a, b, c, d, e, f, g$, compute the final result as a mixed fraction $h \dfrac{i}{j}$.

Limits

The ranges of numbers are as follow. $a$ and $e$ are non-zero and between -100 and 100 inclusively. $b$, and $f$ are non-negative and no more than 100. $c$ and $g$ are positive and no more than 100. $d$ is always between 0 and 3 inclusively.

Input

$a, b, c, d, e, f, g$

Output

The output follows the same rules as the input. You should output $h$, $i$, and $j$ in three lines.

Sample input

1
3
4
0
-2
3
4

Sample output

-1
0
1

Sample input

2
0
1
2
-1
1
3

Sample output

-2
2
3

Discussion