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<queue>
#include<list>
#include<stdio.h>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ull unsigned long long int
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORD(i,n) for(int i=(n)-1;i>=0;--i)
#define znakow 26
#define dcout 0 && cout
#define INF 9999999
int inline min(int a,int b){return a>b?b:a;}
int inline max(int a,int b){return a<b?b:a;}
char*wrap(int k){
	char*b = new char[1000];
	if(k==1){
		b[0]='1';b[1]=0;
		return b;
	}
	char*half=wrap(k/2);
	if(k&1){	
		sprintf(b, "(%s*(1+1)+1)", half);
	}else{
		sprintf(b, "(%s*(1+1))", half);
	}
	delete[] half;
	return b;
}
int main(){
	int tests;
	cin>>tests;
	FOR(test,tests){
		int k;
		cin>>k;
		cout<<wrap(k)<<endl;
	}
    return 0;
}