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
#include <cstdio>

using namespace std;

int tab[100];
int t;

void clear() {
    for (int i = 0; i < 100; ++i) {
        tab[i] = 0;
    }
}

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

    int op = 0, braces = 0;

    while (x > 2) {
        if (x % 2 == 0) {
            tab[op] = 2;
            x /= 2;
        } else {
            tab[op] = 1;
            --x;
            ++braces;
        }
        ++op;
    }

    for (int i = 0; i < braces; ++i) {
        printf("(");
    }

    printf("(1+1)");

    for (int i = op - 1; i >= 0; i--) {
        if (tab[i] == 1) {
            printf("+1)");
        } else {
            printf("*(1+1)");
        }
    }
    printf("\n");
}

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

    for (int i = 0; i < t; ++i) {
        int n;
        scanf("%d", &n);
        solve(n);
        clear();
    }
    return 0;
}