Hide

Problem H
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 x1 y1 op x2 y2. Here, 109x1,y1,x2,y2<109 are integers, indicating that the operands are x1/y1 and x2/y2. The operator op is one of ’+’, ’’, ’’, ’/’, indicating which operation to perform.

You may assume that y10, y20, and that x20 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
Hide

Please log in to submit a solution to this problem

Log in