#K7901. Balanced Chemical Reactions

    ID: 35213 Type: Default 1000ms 256MiB

Balanced Chemical Reactions

Balanced Chemical Reactions

You are given a series of chemical reactions expressed in the format Reactants -> Products. Each side of the reaction consists of one or more chemical formulas separated by the '+' symbol. Each chemical formula can optionally be prefixed by an integer coefficient that represents the number of molecules.

A chemical reaction is balanced if for every element, the total count of that element on the reactants side is equal to the total count on the products side. Otherwise, the reaction is unbalanced.

For example, the reaction below

$$H_2 + O_2 \to H_2O$$

is unbalanced because the left side contains 2 hydrogen atoms and 2 oxygen atoms, whereas the right side has 2 hydrogen atoms and only 1 oxygen atom.

Your task is to determine whether each given reaction is balanced. If it is, output "Balanced"; otherwise, output "Unbalanced".

inputFormat

The first line contains an integer $$T$$, representing the number of chemical reactions. Each of the following $$T$$ lines contains a single chemical reaction in the format described above.

outputFormat

For each reaction, output a single line with either "Balanced" if the reaction is balanced, or "Unbalanced" if it is not.

## sample
1
H2 -> H2
Balanced

</p>