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
//Jedynki
#include <cstdio>


void print_ones(int k) {
	if(k == 3) {
		printf("1+1+1");
		return;
	}
	if(k == 2) {
		printf("1+1");
		return;
	}
	if(k == 1) {
		printf("1");
		return;
	}
	printf("(1+1)*(");
	print_ones(k/2);
	printf(")");
	if(k % 2 == 1) {
		printf("+1");
	}
}

int main() {
	int n, k;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &k);
		int l = k;
		int min_len = 0;
		while(l > 1) {
			if(l % 2 == 0) {
				min_len += 2;
			} else {
				min_len += 3;
			}
			l /= 2;
		}
		if(min_len > 100) {
			printf("NIE\n");
		} else {
			print_ones(k);
			printf("\n");
		}
	}
	return 0;
}