Problem F

Equating Equations

Input: standard input

Output: standard output

Time Limit: 6 seconds

Memory Limit: 32 MB

 

Read equations with up to 16 terms and + and operators (not unary) and reorder the terms (but not the operators) so that the equations hold. For example

 
   1 + 2 = 4 - 5 + 6

is not a correct equation but the terms can be rearranged thus so it is:

 
   6 + 2 = 4 - 1 + 5

Input

Standard input consists of several pseudo-equations, one per line. Each pseudo-equation has up to 16 integer terms and each term is less than 100. Adjacent terms are separated by one operator, and spaces always appear surrounding the terms. There is exactly one = operator in the equation

Output

Your output will consist of one line per input line, with the same operators and the same terms. The order of the operators must be preserved, but the terms can be reordered so the equation holds. Any ordering such that the equation holds is correct. If there is more than one ordering any one of the orderings will do. If no ordering exists, a line containing

   no solution

should be printed. One space should appear on either side of each operator and there should be no other spaces.

Sample Input

1 + 2 = 4 - 5 + 6
1 + 5 = 6 + 7

Sample Output

6 + 2 = 4 - 1 + 5
no solution

(The Decider Contest, Source: Waterloo ACM Programming Contest)