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
#include <iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include <vector>
#include<bitset>
#define ll long long
using namespace std;


string doit(int v) {
    string s = bitset<32>(v).to_string();
    string x ="";
    int res =0;
    for(int i=0;i<s.size();i++){
        char c = s[i];
        res*=2;
        if(res>0){
            if(res>2)x = "("+x+")";
            x += "*(1+1)";
        }
        if(c=='1'){
			res++;
			if(res>1)x+="+";
			x+="1";
		}
	}
    return x;
}

int main()
{
    int t;
    cin >> t;
    while(t--) {
        int x;
        cin >>x;
        cout << doit(x)<<endl;
    }
    return 0;
}