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

/**
 * Created by tom on 2016-11-22.
 */
public class jed {

  private int N;
  private int[] input;


  public String solveSingularNotation() {

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < N; i++) {
      solveSingularNotation(input[i], sb);
      sb.append("\n");
    }


    return sb.toString();
  }

  private void solveSingularNotation(int n, StringBuilder sb) {
    if (n == 1) {
      sb.append("1");
    } else {
      if (n % 2 == 1) {
        sb.append("1+");
        solveSingularNotation(n - 1, sb);
      } else if (n == 2) {
        sb.append("1+1");
      } else {
        sb.append("(1+1)*(");
        solveSingularNotation(n / 2, sb);
        sb.append(")");
      }
    }
  }


  void readInput() {
    this.N = nextInt();
    input = new int[N];
    for (int i = 0; i < N; i++) {
      input[i] = nextInt();
    }
  }


  public static void main(String[] args) {
    jed jed = new jed();
    jed.readInput();
    System.out.println(jed.solveSingularNotation());
  }

  /********** reader ***********/

  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  StringTokenizer st = new StringTokenizer("");

  private String next() {
    try {
      while (!st.hasMoreTokens()) {
        String str;
        str = br.readLine();
        if (str == null)
          return null;
        st = new StringTokenizer(str);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    return st.nextToken();
  }

  private int nextInt() {
    return Integer.parseInt(next());
  }
}