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
//Pawel Kura, zadanie Jedynki

#include <bits/stdc++.h>

using namespace std;


map<int, string> M;
string gen(int x) {
    auto it = M.find(x);
    if (it != M.end()) return it->second;


    auto s = gen(x/2);
    s = "(" + M[2] + ")*(" + s + ")";
    if (x%2 == 1) {
        s += "+1";
    }
    M[x] = s;
    return s;
}

int main() {
    M[1] = "1";
    M[2] = "1+1";
    M[3] = "1+1+1";
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        string s = gen(n);

        int c = 0;
        for (auto x: s) {
            if (x == '1')
                c++;
        }

        if (c > 100) {
            cout << "NIE\n";
        } else {
            cout << s << "\n";
        }
    }

    return 0;
}