Chemistry#7209

Chemistry

1 second
64 megabytes
Easy

Create a program that:

Input

The input consists of the chemical formulas of the reactants, separated by a + sign and positioned to the left of the = sign, and the products, also separated by a + sign, positioned to the right of the = sign. The total number of substances (both reactants and products) does not exceed . All chemical element symbols (in the -st line) begin with uppercase Latin letters. If a compound contains more than atom of an element, this is indicated with a subscript number (in the -nd line). A single formula may contain multiple occurrences of the same element symbol. If a compound includes several identical groups of atoms, these are enclosed in parentheses, with the number of repetitions indicated as a subscript to the right of the closing parenthesis. Spaces in the first line appear only above the numbers in the second line, and the first line does not end with spaces. The input guarantees a unique solution exists.

Output

The output is generated by inserting coefficients, other than , into the first line and aligning the corresponding number of spaces in the second line beneath these coefficients.

Examples

Example 1

Loading
Loading