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
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::string;

string solve(int n) {
    switch(n) {
        case 1:
            return "1";
        case 2:
            return "(1+1)";
        case 3:
            return "(1+1+1)";
    }
    return "(" + solve(n / 2) + "*(1+1)" + (n % 2 == 1 ? "+1" : "") + ")";
}

int main() {
    std::ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        cout << solve(n) << '\n';
    }
    return 0;
}