An elementary-school algebra textbook author needs a program that solves simple algebra equations one step at a time, so the solutions manual can be prepared without human error.
Every problem is an algebraic equality made of integer constants, the four basic arithmetic operators (+, -, *, /), an equals sign, and a variable, for example 12 - 4 * 3 = x.
The equation must not merely be solved; it must be reduced one operation at a time following the standard order of operations. All multiplications and divisions are performed first, from left to right, and then all additions and subtractions, from left to right. At each step exactly one operation — the left-most operation of the highest precedence currently present — is carried out, and the resulting equation is written on its own line. You may assume every division is exact (it always yields an integer).
The input contains several equations, one per line, until end of file.
Each equation has from 1 to 20 operations and therefore from 2 to 21 integer operands (there is always exactly one more operand than there are operators). An operand may carry a leading unary sign (+ or -). Spaces between operators and operands are optional and may be absent entirely. The variable name on the right-hand side is 1 to 8 alphabetic characters.
For each equation, first print the equation itself, then print one line after every single operation, until only one value remains on the left-hand side.
Format each line with exactly one space between every operand, operator, and the = sign (e.g. 2 * -3 + -6 - 4 = r). Write a negative operand with a leading -; write a non-negative operand with no sign (a leading unary + from the input is dropped). Separate the output of consecutive equations with one blank line.