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
#include <stdio.h>

void solve(long long k) {
	if (k == 0) {
		return;
	} else if (k == 1) {
		printf("1");
		return;
	} else if (k == 2) {
		printf("(1+1)");
		return;
	}

	long long mod = k % 3;
	long long div = k / 3;
	if (mod == 0) {
		printf("((1+1+1)*");
		solve(div);
		printf(")");
	} else if (mod == 1) {
		printf("(1+(1+1+1)*");
		solve(div);
		printf(")");
	} else if (mod == 2) {
		printf("(1+1+(1+1+1)*");
		solve(div);
		printf(")");
	}
}

int main() {
	long long t, k;
	scanf("%lld", &t);
	while(t--) {
		scanf("%lld", &k);
		solve(k);
		printf("\n");
	}
	return 0;
}