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
58
59
60
61
62
63
64
65
66
#include <cstdio>
#include <string>


int max = 0;


std::string print(int k)
{
    if (max > 100)
    {
        return std::string("NIE");
    }

    if (k == 1)
    {
        ++max;
        return "1";
    }

    int r = k & 1;
    k = k >> 1;

    std::string w;
    if (k != 1)
    {
        max += 2;
        w = std::string("(1+1)*(") + print(k) + ")";
    }
    else
    {
        max += 2;
        w = std::string("1+1");
    }

    if (r == 1)
    {
        w += "+1";
        ++max;
    }

    if (max > 100)
    {
        return std::string("NIE");
    }

    return w;
}


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

    for (int i = 0; i < t; ++i)
    {
        max = 0;
        int k;
        scanf("%d", &k);

        printf("%s\n", print(k).c_str());
    }

    return 0;
}