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


string solve(int k, int k0)
{
    if(k == 1)
        return "1";
    else if(k == 2)
        return "(1+1)";

    if(k % 2)
    {
        if(k == k0)
            return solve(k - 1, k0) + "+1";
        else
            return "(" + solve(k - 1, k0) + "+1)";
    }
    else
    {
        if(k % 4 == 0 || k == k0)
            return solve(k / 2, k0) + "*(1+1)";
        else
            return "(" + solve(k / 2, k0) + "*(1+1))";
    }
}


int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int k;
        scanf("%d", &k);

        string res = solve(k, k);
        size_t sum = count(res.begin(), res.end(), '1');

        if(sum <= 100)
            printf("%s\n", res.c_str());
        else
            printf("NIE\n");
    }

    return 0;
}