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
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

void print2()
{
	printf("(1+1)");
}
void print3()
{
	printf("(1+1+1)");
}
void print5()
{
	printf("(1+1+1+1+1)");
}
void print1()
{
	printf("1");
}
void print235(int i)
{
	if (i==2) print2();
	else if (i==3) print3();
	else if (i==5) print5();
	else if (i==1) print1();
}

void printNumbers(vector<int> nums)
{
	if (nums.size() == 1)
	{
		print235(nums[0]);
		return;
	}
	int wasOne = 0;
	for (int i =0 ; i<nums.size() ; i++)
	{
		if (nums[i] == 1)
		{
			printf("(1+");
			wasOne++;
		}
		else
		{
			print235(nums[i]);
			if (i!=nums.size()-1)
			{
				printf("*");
			}
		}
	}
	for (int p=0;p<wasOne;p++) printf(")");
}
int main()
{
	int T;
	scanf("%d", &T);
	for (int t = 0;t<T;t++)
	{
		int K;
		scanf("%d", &K);
		if (K==1)
		{
			print1();
			printf("\n");
			continue;
		}
		int n = 0;
		vector<int> numbers;
		bool first = true;
		if (!first)
		{
			printf("+");
		}
		first=false;
		while (n<100 && K>1)
		{
			if (K%2 == 0)
			{
				K/=2;
				numbers.push_back(2);
				n++;
			}
			else if (K%3 == 0)
			{
				K/=3;
				numbers.push_back(3);
				n++;
			}
			else if (K%5 == 0)
			{
				K/=5;
				numbers.push_back(5);
				n++;
			}
			else
			{
				numbers.push_back(1);
				n++;
				K--;
			}

		}

		if (n>=100)
		{
			printf("NIE\n");
		}
		else
		{
			printNumbers(numbers);
		}

		printf("\n");

	}
	return 0;
}