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
62
63
//
//  main.cpp
//  JED
//
//  Created by Faustyna Krawiec on 23/11/2016.
//  Copyright © 2016 Faustyna Krawiec. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int ones(int n, vector<int> &tab){
    int ctr=0,i=2;
    if(n%2){
        ctr++;
        tab.push_back(1);
    }
    n/=2;
    while(n){
        if(n%2){
            ctr+=i;
            tab.push_back(i);
        }
        i+=2;
        n/=2;
    }
   // cout << ctr << endl;
    return ctr;
}

int main(int argc, const char * argv[]) {
    cin.sync_with_stdio(false);
    int tests; cin >> tests;
    while(tests--){
        int n; cin >> n;
        if(n==1){
            cout << '1' << endl;
            continue;
        }
        vector<int> tab;
        if(ones(n, tab)>100 ){
            cout << "NIE" << endl;
            continue;
        }
        int i=0;
        if(tab[0]==1){
            cout << "1+" ;
            i=1;
        }
        for(;i<tab.size()-1;i++){
            cout << "(1+1)";
            for(int j=2;j<tab[i];j+=2)
                cout << "*(1+1)";
            cout << '+';
        }
        cout << "(1+1)";
        for(int j=2;j<tab[tab.size()-1];j+=2)
            cout << "*(1+1)";
        cout << endl;
    }
    return 0;
}