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
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int counter;

string divideAndWin(long long int x) {
  if(x==1) {
    counter++;
    return "1";
  }
  if(x==2) {
    counter+=2;
    return "1+1";
  }
  if(x==3) {
    counter+=3;
    return "1+1+1";
  }
  string s = divideAndWin(x/2);

  if(x%2 == 0) {
    counter += 2;
    return string("(")+s+")*(1+1)";
  } else {
    counter += 3;
    return string("(")+s+")*(1+1)+1";
  }
}

int t;

int main() {
  cin>>t;
  for(int i = 0; i< t; ++i) {
    counter = 0;
    long long int k;
    cin>>k;
    string s = divideAndWin(k);
    if(counter > 100)
      cout<<"NIE\n";
    else cout<<s<<"\n";
  }

}