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
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

#define NUSV1 dkjaskdjfkwui  //zmienna normalnie nie używana w kodzie
#define NUSV2 dkjaskdjhkass

#define POW(i,n) for(int i=0;i<n;++i)
#define POWback(i,n) for(int i=n-1;i>=0;--i)
#define POW_od_do(i,od,n) for(int i=od;i<n;++i)
#define POWod1(i,n) for(int i=1;i<n+1;++i)
//#define POWvec(it,v) for(typeof(v.begin()) it=v.begin();it!=v.end();++it)

// #define MAX(a,b) ((a)>(b) ? (a) : (b))
// #define MIN(a,b) ((a)<(b) ? (a) : (b))
// #define ABS(a) ((a)>0 ? (a) : (-(a)))
#define SQ(a) ((a)*(a))

#define CASE break; case
#define SC second
#define FT first
#define PB push_back
#define MP make_pair
#define INFlli 9223372036854775000
#define INFint 2147483000

typedef long long int LLi;

//better_use_g++_param//#define DEBUG

#ifdef DEBUG
#define LOGendl {cout << "\n" << flush;}
#define LOG(var) {cout << (var) << " " << flush;}
#define LOGv(var) {cout << #var << "=" << (var) << " " << flush;}
#define LOGtab(a,tab) {POW(alala,a) LOG(tab[alala]) LOGendl}
#define LOGtab2(a,b,tab) {POW(alala2,a) LOGtab(b,tab[alala2]) LOGendl}
#define D(...) __VA_ARGS__
#define kreska {POW(alala,5) cout << "-"; cout << "\n" << flush;}
#define kreskai(i) {POW(alala,5*i) cout << "-"; cout << "\n" << flush;}
#define ASSERT(arg) assert(arg)
#define FASTIOSTREAM {LOG("debug") LOGendl kreskai(4) LOG("WARNING!!! DEBUG ON!") LOGendl kreskai(4)}
#else
#define LOGtab2(a,b,tab)
#define LOGtab(a,tab)
#define LOG(var)
#define LOGv(var)
#define D(...)
#define LOGendl
#define kreska
#define kreskai(i)
#define ASSERT(arg)
#define FASTIOSTREAM ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

using namespace std;

void solve(int var)
{
    switch (var)
    {
    case 1:
        cout << 1;
        return;
    case 2:
        cout << "1+1";
        return;
    case 3:
        cout << "1+1+1";
        return;
    }
    cout << '(';
    solve(var/2);
    cout << ")*(1+1)";
    if (var%2==1)
        cout << "+1";
}

int main()
{
	FASTIOSTREAM
    int t;
    cin >> t;
    for (int asd=0;asd<t;asd++)
    {
        int var;
        cin >> var;
        solve(var);
        cout << "\n";
    }
    return 0;
}