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>

using namespace std;

void print(long long int n){
	vector <int> v;
	int licz=0;
	if(n==1){
		cout<<"1";
		return;
	}
	while(n>1){
		if(n%2==0){
			v.push_back(2);
			n/=2;
		}
		else{
			v.push_back(1);
			n-=1;
		}
	}
	for(int i=0; i<v.size(); ++i){
		//cout<<v[i]<<" ";
		if(v[i]==2){
			cout<<"(1+1)";
			if((i+1)<v.size()){
				cout<<"*";
				if(v[i+1]==1){
					cout<<"(";
					++licz;
				}
			}	
		}
		else{
			cout<<"1";
			if((i+1)<v.size()){
				cout<<"+";
			}
		}
	}
	for(int i=0; i<licz; ++i){
		cout<<")";
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	int k;
	long long int n;
	cin>>k;
	for(int i=0; i<k; ++i){
		cin>>n;
		print(n);
		cout<<endl;
	}
	return 0;
}