Expression

For each pair (x, y) print a postfix expression over x, +, -, *, / whose value is y, using the fixed construction the statement describes.

Medium6Dynamic programmingImplementationBrute forceNo attempts yetTime limit4sMemory limit512 MB

Problem

Here is a puzzle. Can you write a mathematical expression that evaluates to 113113 and uses nothing but common mathematical symbols and four copies of the digit 44?

One answer is

113=4+(4+4!)%4%113 = \frac{\sqrt{4} + (\sqrt{4} + 4!)\%}{\sqrt{4}\%}

Here ! is the factorial sign and % is the percent sign, so 11% = 0.11.

Four fours is an arithmetic puzzle whose goal is to produce a given number from four copies of the digit 44 and common mathematical symbols. Some numbers are easy: 16=4+4+4+416 = 4 + 4 + 4 + 4. Others are not, as the expression for 113113 shows. Can you produce 20162016 from four fours?

This problem is a variation of that puzzle. You are given two integers xx and yy, and you have to write an expression whose value is yy under these rules.

  • The only constant allowed in the expression is the integer xx.
  • The only operations allowed are addition, subtraction, multiplication and division.
  • The expression uses at most 2828 operations.
  • No intermediate result exceeds 101810^{18} in absolute value.
  • Every division is exact, so the divisor is not zero and the quotient is an integer.

Many expressions can satisfy these rules at once. The output section fixes one of them, and that is the expression you print.

Input

The first line contains an integer TT, the number of test cases.

Each of the next TT lines contains two integers xx and yy separated by a space.

  • 1T2121211 \le T \le 212121
  • 0x,y<12120 \le x, y < 1212

Output

For each test case print one line.

An expression is written in postfix notation as a string over the five characters x, +, -, * and /. It is evaluated with a stack that starts empty, reading the string from left to right.

  • x pushes the number xx onto the stack.
  • + pops two numbers bb and aa in that order, then pushes a+ba + b.
  • - pops bb and aa, then pushes aba - b.
  • * pops bb and aa, then pushes a×ba \times b.
  • / pops bb and aa, then pushes a/ba / b.

After the last character the stack must hold exactly one number, and that number is the value of the expression. If an operator is read while the stack holds fewer than two numbers, or the stack does not hold exactly one number at the end, the evaluation fails.

Print the expression that this rule selects.

  • If x=0x = 0 and y>0y > 0, print IMPOSSIBLE.
  • If y=0y = 0, print xx-.
  • Otherwise print S(y)S(y) followed by x/.

S(n)S(n) is defined for 1n12111 \le n \le 1211 and is a postfix string whose value is n×xn \times x. Let c(n)c(n) be the number of x characters in S(n)S(n). The base string for n=1n = 1 is x, so c(1)=1c(1) = 1. Three rules build the other strings.

  • Product: if n=a×bn = a \times b with 2ab12112 \le a \le b \le 1211, concatenate S(a)S(a), then S(b)S(b), then *x/. The result holds c(a)+c(b)+1c(a) + c(b) + 1 characters x.
  • Sum: if n=a+bn = a + b with 1ab12111 \le a \le b \le 1211, concatenate S(a)S(a), then S(b)S(b), then +. The result holds c(a)+c(b)c(a) + c(b) characters x.
  • Difference: if n=abn = a - b with 1b<a12111 \le b < a \le 1211, concatenate S(a)S(a), then S(b)S(b), then -. The result holds c(a)+c(b)c(a) + c(b) characters x.

c(n)c(n) is the smallest number of x characters over every string these rules build for nn, and S(n)S(n) is a string that reaches c(n)c(n). When several strings reach it, take a product first, then a sum, then a difference, and inside one kind take the smallest aa. The two parts of such a string always satisfy c(a)<c(n)c(a) < c(n) and c(b)<c(n)c(b) < c(n), so S(n)S(n) is determined for every nn.

The expression printed this way uses at most 2828 operations.