#include <iostream>
#include <cstdlib>

using namespace std;

class Parser {
    private:
       istream* is;
       char     tok;    // ultimo atomo leido
       double   dbl;    // ultimo double leido
    public:
       Parser(istream& s); 
       char lex();        // avanza un atomo
       char Tok() const;  // reporta el ultimo atomo leido
       double Dbl() const;  // reporta el ultimo num leido
       void Term(double& coef, int& expo); // lee un termino
};

Parser::Parser(istream& s)
{
    is= &s;
    lex();
}

char Parser::lex()
{
    while ( !is->eof() && isspace(is->peek()) )
       is->get(); 

    if (is->eof())
       return tok= '#';

    int c= is->get();      // ultimo caracter leido
    switch (c) {
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
            is->putback(c);
            *is >> dbl;
            return tok= 'n'; 
        case '+':
        case '-':
        case ';':
            return tok= c;
        case 'x':
        case 'X':
            return tok= 'x';
        default:
            return tok= '#';
       }
}

char Parser::Tok() const
{
    return tok;
}

double Parser::Dbl() const
{
    return dbl;
}

void Parser::Term(double& coef, int& expo)
{
   if (Tok() == 'n')
      {
       coef= Dbl();
       lex();
       if (Tok() == 'x')
          {
           lex();
           if (Tok() == 'n')
              {
               expo= (int)Dbl();
               lex();
              }
           else
              expo= 1;
          }
       else
          expo= 0;
      }
   else
      if (Tok() == 'x')
         {
          lex();
          coef= 1.0;
          if (Tok() == 'n')
             {
              expo= (int)Dbl();
              lex();
             }
           else
             expo= 1;
         }
      else
         {
          cerr << "ERROR- se espera termino\n";
          coef= 0;
          expo= 0;
         }
}


int main(int argc, char* argv[])
{
   Parser P(cin);

   while ( P.Tok() != '#' )
      {
       double c;
       int    e;
       P.Term(c,e);
       cout << c << "x**" << e << endl;
      }
   return EXIT_SUCCESS;
}



