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
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

#define MP make_pair
#define ST first
#define ND second

int maxBitOf(unsigned int n){
	int res = 0;
	while( (1u<<res) <= n) res++;
	return res-1;
}

void solve(unsigned int n){
	if (n < 4){
		switch(n){
			case 1: cout << "1" << endl; return;
			case 2: cout << "1+1" << endl; return;
			case 3: cout << "1+1+1" << endl; return;
		}
	}

	int maxBit = maxBitOf(n);

	string res;

	switch( n >> (maxBit-1) ){
		case 2: res = "1+1"; break;
		case 3: res = "(1+1)+1"; break;
		default: cout << "n >> (maxBit-2): " << (n >> (maxBit-2)); throw exception();
	}
	
	for(int i=maxBit-2; i>=0; i--){
		res = "("+res+")*(1+1)";
		if (n & (1<<i))
			res = res+"+1";
	}

	cout <<  res << endl;    
}


int main(){
    ios_base::sync_with_stdio(false);
    int z;
    cin >> z;
    while(z--){
        unsigned int n;
        cin >> n;
    	solve(n);
    }

    return 0;
}