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
import java.awt.datatransfer.StringSelection;
import java.util.*;



    public class jed {
    	
    	public static final String ONE = "1";
    	public static final String TWO = "(1+1)";
    	public static final String THREE = "(1+1+1)";
    	public static final String FIVE = "(1+1+1+1+1)";
    	public static final String SEVEN = "((1+1)*(1+1+1)+1)";
    	
    	
    	public static String divideToOnes(int t){
    		if(t == 1){
				return ONE;
			}
    		
    		StringBuilder result = new StringBuilder();
    		boolean isDivided = true;
    		
    		while(isDivided){
    			isDivided = false;
    			
    			while (t%2 == 0) {   		
    				result.append(TWO);
    				t=t/2;
    				if(t > 1){
    					result.append("*");
    					isDivided = true;
    				}
    			}
        		
    			while(t%3 == 0){
    				result.append(THREE);
    				t=t/3;
    				if(t > 1){
    					result.append("*");
    					isDivided = true;
    				}
    			}
    			
    			while(t%5 == 0){
    				result.append(FIVE);
    				t=t/5;
    				if(t > 1){
    					result.append("*");
    					isDivided = true;
    				}
    			}
    			
    			while(t%7 == 0){
    				result.append(SEVEN);
    				t=t/7;
    				if(t > 1){
    					result.append("*");
    					isDivided = true;
    				}
    			}
    		}
    			if(t > 1){
    				t -= 1;
    				result.append("(1+").append(divideToOnes(t)).append(")");
    				
    			}
    		
    		return result.toString();
    	}
    	
    	
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
          
                       
        	for(int i = 0; i < n; i++)
        	{     		     
        		int t = in.nextInt(); 
        		        		
       
        		System.out.println(divideToOnes(t));
           
        	}
        	        
        	in.close();
        	
        }
    }