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
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <utility>
#include <queue>
#include <list>
#include <iomanip>
#include <set>

#define PI 3.14159265

using namespace std;

int k;
string res;
list<int> binary;


inline void read_input()
{
  cin >> k;
}

bool count_ones(string s)
{
  int res = 0;
  for (int i = 0; i < s.size(); ++i)
    if (s[i] == '1') res++;
  return (res <= 100);
}

inline void print_output()
{
  if (count_ones(res))
    cout << res << endl;
  else
    cout << "NIE" << endl;
}

inline void clear_vars()
{
  binary.clear();
}

inline void get_bin(int number)
{
  while (number > 0)
  {
    if (number % 2 == 1)
      binary.push_front(1);
    else
      binary.push_front(0);
    number = number / 2;
  }
}

inline void add1(string& s)
{
  stringstream ss;
  ss << "(" << s << "+1)";
  s = ss.str();
}

inline void mult2(string& s)
{
  s = s + "*(1+1)";
}

void solve()
{
  clear_vars();
  get_bin(k);
  auto it = binary.begin();
  // first bit is for sure 1 => no number starts with 0
  it++;
  if (it == binary.end())
    res = "1";
  else
  {
    if ((*it) == 1)
      res = "(1+1+1)";
    else
      res = "(1+1)";
    it++;
  }
  while (it != binary.end())
  {
    mult2(res);
    if ((*it) == 1)
      add1(res);
    it++;
  }
}


int main(int argc, const char *argv[])
{
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i)
  {
    read_input();
    solve();
    print_output();
  }
  return 0;
}