Fraction to Repeating Decimal

Write each given fraction as its decimal form with the shortest nonrepeating part and the repeating block in parentheses.

Medium5Hash mapMathSimulationInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

Every rational number can be written as a repeating decimal, where from some position on the same block of digits repeats forever.

13=39=0.3333333=0.3\frac{1}{3} = \frac{3}{9} = 0.3333333\dots = 0.\overline{3}

17=142857999999=0.14285714285714=0.142857\frac{1}{7} = \frac{142857}{999999} = 0.14285714285714\dots = 0.\overline{142857}

314=21428559999990=0.2142857142857=0.2142857\frac{3}{14} = \frac{2142855}{9999990} = 0.2142857142857\dots = 0.2\overline{142857}

The denominators above are made of nothing but 9s and 0s, and that pattern is exactly the standard recipe for turning a repeating decimal back into a fraction. Starting from an arbitrary fraction, that recipe is hard to apply, so the usual way to convert a fraction into a repeating decimal is repeated long division. Doing it by hand takes a lot of work, so write a program that does it for you.

Input

The first line contains the number of test cases TT (1T150001 \le T \le 15000).

Each of the next TT lines contains a numerator aa and a denominator bb as integers separated by a space, with 0a<10240 \le a < 1024 and 0<b<10240 < b < 1024.

Output

For each test case, print the repeating decimal of a/ba/b on its own line.

Write the integer part, a period, the non-repeating fractional digits, then the repeating block wrapped in parentheses. When the non-repeating part is empty, the opening parenthesis comes right after the period. A fraction whose division comes out even still gets (0)(0), because zeros repeat forever after the last digit. Take the shortest possible non-repeating part and the shortest possible repeating block.