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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class jed {
	
	private static final int maxOneCount = 100;
	
	public static void main(String[] args) {
		try {
			BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer tokenzier = new StringTokenizer(buffReader.readLine());
			
			int t = Integer.parseInt(tokenzier.nextToken());
			int numbers[] = new int[t];
			for(int i = 0; i < t; i++){
				tokenzier = new StringTokenizer(buffReader.readLine());
				numbers[i] = Integer.parseInt(tokenzier.nextToken());
			}
			
			for(int i = 0; i < t; i++){
				int number = numbers[i];
				if(number < 4){
					System.out.println(number == 3 ? "1+1+1" : number == 2 ? "1+1" : "1");
				}else{
					int oneCount = 0;
					StringBuilder result = new StringBuilder(maxOneCount*10);
					int mask = Integer.highestOneBit(number);
					while(mask > 2){
						mask >>= 1;
						if((mask & number) > 0)
							result.append("(");
					}
					mask = Integer.highestOneBit(number);
					while(mask > 2){
						mask >>= 1;
						if((mask & number) > 0){
							result.append("(1+1)+1)*");
							oneCount += 3;
						}else{
							result.append("(1+1)*");
							oneCount += 2;
						}
					}
					mask >>= 1;
					if((mask & number) > 0){
						result.append("(1+1)+1");
						oneCount += 3;
					}else{
						result.append("(1+1)");
						oneCount += 2;
					}
					System.out.println(oneCount > maxOneCount ? "NIE": result);
					
				}
			}
						
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}