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

using namespace std;

int count_ones(int num) {
	if (num == 1)
		return 1;

	int count = 0;
	while (num > 1) {
		if (num & 1) {
			count ++;
			num--;
		}

		num /= 2;
		count +=2 ;
	}

	return count;
}


void dump(int num) {
	if (num == 1) {
		printf("1\n");
		return;
	}

	int open = 0;
	while (num > 1) {
		if (num & 1) {
			open++;
			printf("(1+");
		}

		printf("(1+1)");
		num /= 2;

		if (num > 1) {
			printf("*");
		}
	}

	for (int i = 0; i < open; i++)
		printf(")");
	printf("\n");

}

int main() {
	int c, num;
	scanf("%d", &c);

	for (int i = 0; i < c; i++) {
		scanf("%d", &num);
		if (count_ones(num) > 100)
			printf("NIE\n");
		else
			dump(num);
	}

	return 0;

}