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
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <list>
#include <algorithm>
#include <math.h>
#define FOR(x,y,z) for(int x = (y); x < (z); x++)
#define FORD(x,y,z) for(int x = (y); x >= z; x--)
#define REP(r,n) for(int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define MAXUS (1<<20)+1
#define ND second
#define PB push_back
#define MAXUS2 9000005
#define PI 3.1415926
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i,x) for (__typeof((x).begin()) i=(x).begin(); i!=(x).end(); i++)
#define ALL(u) (u).begin(),(u).end()
#define epsilon 0.000001

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int, int> PR;


int in[MAXUS];
int main() {
   ios_base::sync_with_stdio(0);
	int t;
	cin >> t;
	int n;
	list<char> result;
	while (t--) {
		cin >> n;
		if (n == 1) {
			cout << "1" << endl;
			continue;
		}
		int counter = 0;
		result.clear();
		bool was = false;
		bool end = false;
		int globalCounter = 0;
		while (n > 0) {
			int k = 1;
			int counter = 0;
			while (k*2 <= n) {
				k*=2;
				counter+=2;
			}
			n -=k;
			if (was) {
				result.push_back('+');
				// if (k != 1) result.push_back('(');
			}
			if (k == 1) {
				globalCounter++;
				result.push_back('1');
			}
			else if (counter == 2) {
				globalCounter+=2;
				result.push_back('1');	
				result.push_back('+');
				result.push_back('1');
			}
			else {
				while (counter > 0) {
					globalCounter += 2;
					result.push_back('(');	
					result.push_back('1');	
					result.push_back('+');
					result.push_back('1');		
					result.push_back(')');	
					counter-=2;
					if (counter >= 2) {
						result.push_back('*');
					}
				}
			}
			if (globalCounter > 100) {
				cout << "NIE" << endl;
				end = true;
				break;
			}
			if (was && k != 1) {
				// result.push_back(')');
			}
			if (!was) {
				was = true;
			}
		}
		if (!end) {
			for (char i : result) {
				cout << i;
			}
			cout << endl;
		}
	}
 
	return 0;
}