Formula Substitution

Time limit1sMemory limit128 MB

Problem

Formulas are defined as follows.

  • A constant is one lowercase English letter (a-z).
  • A variable is the digit 0 or 1.
  • A function is one uppercase English letter (A-Z).
  • A formula is a constant, a variable, or function(formula,formula).

Valid formulas include a, 0, F(a,F(a,a)), and G(F(0,1),G(a,1)). The strings A, a(9), and F(G(),a) are not valid formulas.

A formula that contains no variables is called a basic formula.

You are given two formulas. Replace every occurrence of each variable 0 and 1 in both formulas with some basic formula so that the two formulas become exactly identical after replacement.

If the same variable appears more than once, every occurrence of that variable must be replaced by the same basic formula.

Input

The input has two lines. Each line contains one formula, and each formula has at most 100 characters.

Output

On the first line, output the substitution for variable 0. On the second line, output the substitution for variable 1.

Each line must have the format variable=basic formula. Even if a variable does not appear in either input formula, you must still output a substitution for it.

Every input is guaranteed to have at least one solution. The solution does not have to be unique.