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
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <iostream>
#include <vector>
using namespace std;
//vector<vector<int>* > primes;
vector<int> mult;
vector<int> add;
string propose;
bool firstc=true;
int numcount=0;
bool onlyop=true;
void man(int val/*,vector<int>* vec*/) {
	if(!firstc)
		propose+='*';
	else{
		firstc=false;
	}
	for(int i=2;i<=val/2;i++){
		if(val%i==0){
			onlyop=false;
			propose+='(';
			if(i>5){
				//primes.push_back(new vector<int>());
				propose+='(';
				firstc=true;
				man(i/2);
				man(2);
				propose+="+1)";
				numcount++;
			}
			else{
				numcount+=i;
				for(int j=0;j<i;j++){

					if(j!=0){
						propose+='+';
					}
					propose+='1';
				}
				//vec->push_back(val);
			}
			propose+=')';

			//vec->push_back(i);
			man(val/i);
			return;

		}
	}
	if(val>5){
		//primes.push_back(new vector<int>());
		if(!onlyop)
			propose+='(';
		bool prevonlyop=onlyop;
		onlyop=false;
		firstc=true;
		man(val/2);
		man(2);
		onlyop=prevonlyop;
		if(!onlyop)
			propose+="+1)";
		else
			propose+="+1";
		numcount++;
	}
	else{
		if(!onlyop)
			propose+='(';
		numcount+=val;
		for(int j=0;j<val;j++){

			if(j!=0){
				propose+='+';
			}
			propose+='1';
		}
		if(!onlyop)
			propose+=')';

		//vec->push_back(val);
	}

}
int main() {
	ios_base::sync_with_stdio(0);
	int t;
	cin>>t;
	for(int i=0;i<t;i++){
		propose="";
		numcount=0;
		firstc=true;
		onlyop=true;
		mult=vector<int>();
		add=vector<int>();
		int val;
		cin>>val;
		man(val/*,&mult*/);
		if(numcount<=100){
			cout<<propose;
		}
		else{
			cout<<"NIE";
		}
		/*for(vector<int>::iterator it=mult.begin();it!=mult.end();it++){
			int subc=*it;
			if(it!=mult.begin()){
				cout<<'*';
			}
			cout<<'(';
			for(int j=0;j<subc;j++){
				if(j!=0){
					cout<<'+';
				}
				cout<<'1';
			}
			cout<<')';
		}*/
		cout<<endl;
	}
	return 0;
}