1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll n;
ll otwarte;
ll ILE;
ll t;
ll k;
string s;

inline void wys2 ()
{
    s = s + "(1+1)";
}


int main()
{
    ios_base::sync_with_stdio(0);

cin >> t;
while(t--){

   cin >> k;
   n = k;

      if(n == 1) {cout << 1 << endl; continue;}
    if(n == 2) {cout << "1+1\n"; continue;}
        s.clear();
        ILE = 0;
        otwarte = 0;

        while(n > 1)
        {
            if(n % 2 == 0)
            {
                wys2();
                ILE += 2;
                n /= 2;
                if (n > 1) s = s + "*";
                continue;
            }

            if(n < k) {s = s + "(1+"; ++otwarte;}
            else {s = s + "1+";}
            ++ILE;
            n -= 1;
        }


        while(otwarte--)
        s = s + ")";

        if(ILE <= 100) cout << s << endl;
        else cout << "NIE\n";
}

return 0;
}