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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  int z; cin >> z;
  while (z--) {
    int n; cin >> n;
    stack<int> bin;
    while (n > 1) {
      bin.push(n & 1);
      n /= 2;
    }
    int nparens = 0;
    string res = "1";
    for (; !bin.empty(); bin.pop()) {
      res += "*(1+1)";
      if (bin.top()) {
        res += "+1)";
        ++nparens;
      }
    }
    cout << string(nparens, '(') << res << endl;
  }
  return 0;
}