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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#include <math.h>
#include <vector>

using namespace std;


void solve(int n)
{
    if (n == 1)
    {
        printf("1\n");
        return;
    }

    if (n == 2)
    {
        printf("1+1\n");
        return;
    }

    if (n == 3)
    {
        printf("1+1+1\n");
        return;
    }

    vector<int> ones;

    while (n)
    {
        ones.push_back(n%2);
        n /= 2;
    }

    int count = 0;

    for (int i=0;i<ones.size()-1;++i)
    {
        count += ones[i];
    }

    while(count--)
        printf("(");

    bool is_first = true;

    for (int i=ones.size() - 2; i>=0; --i)
    {
        if (!is_first)
            printf("*");

        printf("(1+1)");

        if (ones[i] == 1)
            printf("+1)");

        is_first = false;
    }

    printf("\n");

}

int main()
{
    int t, n;

    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &n);
        solve(n);
    }
    /*for (int i=1;i<=1000000000;++i)
    {
        solve(i);
    }*/

    return 0;
}