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
#include<iostream>
#include<math.h>
using namespace std;

int primes[4000];

long int policz(long int n)
{
	int a,b,c;
	if (n<4) return n;
	b = 1;
	c = (long int)sqrt(n);
	while ((n % primes[b] != 0) && (primes[b] <= c))
	{
		b++;
	}
	
	if (n % primes[b] == 0)
		return policz(primes[b]) + policz(n / primes[b]);
	else 
		return policz(n-1)+policz(1);
}

long int wypisz(long int n)
{
	int a,b,c,part1,part2;
	if (n<4) 
	{
		if (n == 1)
			cout<<"1";
		if (n == 2)
			cout<<"(1+1)";
		if (n == 3)
			cout<<"(1+1+1)";
		return n;
	}
	b = 1;
	c = (long int)sqrt(n);
	while ((n % primes[b] != 0) && (primes[b] <= c))
	{
		b++;
	}
	
	if (n % primes[b] == 0)
	{
		cout<<"(";
		part1 = wypisz(primes[b]);
		cout<<"*";
		part2 = wypisz(n / primes[b]);
		cout<<")";
	}
	else 
	{
		cout<<"(";
		part1 = wypisz(n-1);
		cout<<"+";
		part2 = wypisz(1);
		cout<<")";
	}
	return part1 + part2;
}

int main()
{
	long int n,t,p;
	int sito[32640];
	int b = 1;
	for (int a = 0; a < 32640; a++)
		sito[a] = 1;
	int a = 2;
	while (a<32639)
	{
		if (sito[a] == 1)
		{
			primes[b] = a;
			b++;
			for (int c = a; c < 32640; c+=a)
			{
				sito[c] = 0;
			}
		}
		a++;
	}
	cin>>t;
	while (t>0)
	{
		cin>>n;

		p = policz(n);
		if (p > 100)
			cout<<"NIE";
		else
		{
			p = wypisz(n);
		}
		cout<<"\n";
		t--;
	}
	return 0;
}