Hide

Problem E
Rational Arithmetic

Input

The first line of input contains one integer, giving the number of operations to perform.

Then follow the operations, one per line, each of the form $x_1\ y_1\ \mbox{op}\ x_2\ y_2$. Here, $-10^9 \leq x_1, y_1, x_2, y_2 < 10^9$ are integers, indicating that the operands are $x_1/y_1$ and $x_2/y_2$. The operator op is one of ’$+$’, ’$-$’, ’$*$’, ’$/$’, indicating which operation to perform.

You may assume that $y_1 \ne 0$, $y_2 \ne 0$, and that $x_2 \ne 0$ for division operations.

Output

For each operation in each test case, output the result of performing the indicated operation, in shortest terms, in the form indicated.

Sample Input 1 Sample Output 1
4
1 3 + 1 2
1 3 - 1 2
123 287 / 81 -82
12 -3 * -1 -1
5 / 6
-1 / 6
-82 / 189
-4 / 1

Please log in to submit a solution to this problem

Log in