시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB3000.000%

문제

Consider mathematical formulas defined as follows:

  • a constant is a lowercase letter of the English alphabet ('a'-'z')
  • a variable is the digit '0' or '1'
  • a function is an uppercase letter of the English alphabet ('A'-'Z')
  • a formula is a constant or a variable or a function(formula,formula)

For example 'a', '0', 'F(a,F(a,a))' and 'G(F(0,1),G(a,1))' are formulas, while 'A', 'a(9)' and 'F(G(),a)' are not.

Formulas that don't contain any variables are called basic formulas.

You are given two formulas. Write a program that will substitute every occurrence (in both formulas) of some variable with some basic formula so that, after substitution, the two formulas become identical.

If a variable appears more than once in one or both formulas then each occurrence has to be substituted with the same basic formula. 

입력

Two lines of input contain two formulas. Each will contain at most 100 characters.

출력

The first line of output should contain the substitution for the variable '0', and the second line should contain the substitution for the variable '1'.

In both lines the format should be 'variable=basic formula'. Even if a variable doesn't appear in formulas at all, you should still output a substitution for it.

Note: the test data will be such that a solution, although not necessarily unique, always exists. 

예제 입력 1

0
a

예제 출력 1

0=a
1=b

예제 입력 2

F(0,G(a,1))
F(c,G(a,F(0,0)))

예제 출력 2

0=c
1=F(c,c)

예제 입력 3

F(G(1,a),G(1,a))
F(0,0)

예제 출력 3

0=G(b,a)
1=b