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
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;


int n, x;

string part(int k)
{
	if(k == 1) return "1";
	
	string s;
	vector<int>v;
	int a = 2, sq = sqrt(k), d = k;
	while(d > 1)
	{
		if(a * a > d && v.empty())break;
		
		while(d % a == 0)
		{
			d/=a;
			v.push_back(a);
			//cout<<a<<' ';
		}
		a++;
	}
	
	if(!v.empty())
	{
		for(int i=0;i<v.size();i++)
		{
			s += part(v[i]);
			if(i!=v.size()-1)s += "*";
		}
	}
	else
	{
		if(x != d)s = "(";
		s += part(d-1) + "+1";
		if(x != d)s += ")";
	}
	return s;
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d", &x);
		
		string w = part(x);
		
		int b = 0;
		for(int j=0;j<w.size();j++)
		{
			if(w[j]=='1')b++;
		}
		
		if(b<100)printf("%s\n",w.c_str());
		else
		printf("NIE\n");
	}
	
	
	
	return 0;
}