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

using namespace std;

string draw_ones(int n, bool first)
{
    string s = "";
    if(!first) s+="(";
    for(int i=0;i<n-1;i++)
        s += "1+";
    s += "1";
    if(!first) s+=")";
    
    return s;
}

void do_something(int n)
{
  
    int sum = 0;
    string ss = "";
    for(int d = 2; d <= 100; d++)
    {
      while((n % d) == 0)
      {
        n /= d;
        sum += d;
        ss += draw_ones(d, (n==1 && ss=="")?true:false);
        if (n>1) ss += "*";
      };
      if (sum > 100)
      {
          ss = "NIE";
          break;
      }      
    }
    if (n>1) ss = "NIE";
   cout << ss << "\n";
}



int main()
{
  int n,t;
  cin >> t; 
  for(int i=0;i<t;i++)
  {
       cin >> n;
       do_something(n);
  }
 

return 0;
}