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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
#include<bits/stdc++.h>
using namespace std;

class Solver {
    int n;
    string ans;
    
    void load(istream &is) {
        is >> n;
    }
    
    bool specialCase() {
        if(n == 1) {
            ans = "1";
            return true;
        }
        if(n == 2) {
            ans = "1+1";
            return true;
        }
        return false;
    }
    
    string bin(int n) {
        string m;
        while(n) {
            m.push_back('0' + (n & 1));
            n >>= 1;
        }
        return m;
    }
    
    void buildAns() {
        if(specialCase())
            return;
        
        string rep = bin(n);
        ans = "1+1";
        int i = rep.size() - 2;
        
        if(rep[i] == '1')
            ans += "+1";
        --i;
        
        for(;i >= 0; --i) {
            if(rep[i] == '1')
                ans = "(" + ans + ")*(1+1)+1";
            else
                ans = "(" + ans + ")*(1+1)";
        }
    }
    
public:
    void solve(istream &is) {
        load(is);
        buildAns();
    }
    
    void out(ostream &os) {
        os << ans << endl;
    }
};

// class Verifier {
// public:
//     int calcOnes(string &s) {
//         int ones = 0;
//         for(int i = 0; i < s.size(); ++i)
//             if(s[i] == '1')
//                 ++ones;
//         return ones;
//     }
// };

// int test_main() {
//     Verifier verifier;
//     for(int i = 1000000000 - 1000000; i <= 1000000000; ++i) {
//         stringstream is;
//         stringstream os;
//         is << i;
//         Solver solver;
//         solver.solve(is);
//         solver.out(os);
//         string out;
//         os >> out;
//         if(verifier.calcOnes(out) > 100)
//             cerr << "Too many ones for " << i << endl;
//     }
// }

int _main(istream &is, ostream &os) {
    int t;
    is >> t;
    while(t) {
        --t;
        Solver solver;
        solver.solve(is);
        solver.out(os);
    }
}

int main() {
//     test_main();
    ios_base::sync_with_stdio(0);
    _main(cin, cout);
}