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
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
#include <iostream>
#include <algorithm>
#include <vector>
#include "stdio.h"

#define FOREACH(n) for(int x = 0; x < n; x ++)

using namespace std;

#include <iostream>
#include <cmath>

using namespace std;

vector<int> czynniki(int n)
{
    int g,i;
    vector<int> rozklad;

    g = sqrt(n);

    for(i = 2; i <= g; i++)
    {
        while(n % i == 0)
        {
            rozklad.push_back(i);
            n /= i;
        }

        if(n == 1)
        {
            return rozklad;
        }
    }

    rozklad.push_back(n);
}

string number(int n)
{
    switch(n)
    {
        case 2:
            return "(1+1)";
        break;
        case 3:
            return "(1+1+1)";
        break;
        case 4:
            return "(1+1+1+1)";
        break;
        case 5:
            return "(1+1+1+1+1)";
        break;
    }
}

string ones(int n)
{
    vector<int> a;
    vector<int>::iterator it;
    string b, c;
    a = czynniki(n);

    for(it = a.begin(); it < a.end(); it ++)
    {
        if(*it <= 5)
        {
            b += number(*it);
            if(it != a.end()-1)
                b += "*";
        }
        else
        {
            c = "(";
            c += ones(*it - 1);
            c += "+1)";
            b += c;
            if(it != a.end()-1)
                b += "*";
        }
    }

    return b;
}

int main()
{
    int qualityTest, n, qualityOnes;
    vector<int>::iterator it;
    vector<int> a;
    string result;

    scanf("%d", &qualityTest);

    FOREACH(qualityTest)
    {
    scanf("%d", &n);

    qualityOnes = 0;
    result = ones(n);

    cout<<result<<endl;
    }

    return 0;
}