1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <cstdio>
#include <string>

std::string solve(int n) {
  if (n == 1) return "1";
  std::string res = "(" + solve(n >> 1) + "*(1+1))";
  if (n & 1) res = "(" + res + "+1)";
  return res;
}

int main() {
  int tcase;
  for (scanf("%d", &tcase); tcase--;) {
    int n;
    scanf("%d", &n);
    puts(solve(n).c_str());
  }
  return 0;
}