This page is still under construction.

Parts of this page are still being built. What you see may change.

Ones

Time limit1sMemory limit512 MB

Summary
For each k up to 1e9, output a 1-expression using only ones, +, *, and parentheses that evaluates to k with at most 100 ones, or NO.
Level

Hard8 of 10

Topics
Dynamic programming, Math, Backtracking, Greedy
Solved
No attempts yet

Problem

We define 1-expressions as numeric expressions that contain only ones, addition signs, multiplication signs, and parentheses. In such an expression no two digits may be adjacent: every two ones must be separated by an operator. Expressions follow the usual order of evaluation. For example, multiplication has higher priority than addition.

For example, each of the following 1-expressions evaluates to 6:

(1+1)*(1+1+1), (1+1+1)*(1+1)*1, ((1+1)+1)*(1+1), 1+1+1+1+1+1, 1+(1+(1+(1+(1+1)))).

Formally, the following grammar describes all valid 1-expressions EE:

E ::= 1 | E+E | E*E | (E+E) | (E*E)

Write a program that, given an integer kk (k≤109k \le 10^9), outputs a 1-expression evaluating to kk that contains at most 100 ones.

Input

The first line of the input contains a single integer tt (1≤t≤1001 \le t \le 100), the number of testcases.

Each of the following tt lines describes a single testcase. The ii-th of these lines describes the ii-th test and contains a single integer k_ik\_i (1≤k_i≤1091 \le k\_i \le 10^9).

Output

You must output exactly tt lines.

If no 1-expression evaluates to k_ik\_i and contains at most 100 ones, output NO on the ii-th line. Otherwise, that line must contain a valid expression. Do not print any spaces inside the expression. If there is more than one valid solution, print any of them.

Examples1

  1. Example 1

    Input
    2
    6
    10
    
    Expected output
    (1+1)*(1+1+1)
    1+1+1+1+1+1+1+1+1+1