PROGRAMMING:Reconstruction of binary tree
Given the middle root sequence and back root sequence of a binary tree, write a program to create the binary tree, calculate its height and first root sequence, and finally delete the binary tree; If the given middle root and back root sequences are illegal, they can also be recognized.
###Input format:
The first line represents the back root sequence of a binary tree, and the second line represents its root sequence. The values of the nodes are all capital letters of A-Z, so the number of nodes in the binary tree is not more than 26, and the two input sequences are guaranteed to be full permutation of nodes, but not necessarily legal middle root and back root sequences.
###Output format:
If the input sequence is illegal (not the middle root sequence and the back root sequence of the same tree), invalid will be output. If the input sequence is legal, the output is two lines. The first line is an integer representing the height of the binary tree, and the second line is a string representing the first root sequence of the binary tree.
###Input sample 1:
```in
CEFDBHGA
CBEDFAGH
```
###Output sample 1:
```out
three
ABCDEFGH
```
###Input sample 2:
```in
CBEDFAGH
CEFDBHGA
```
###Output sample 2:
```out
INVALID
```
###Input sample 3:
```in
BCA
CAB
```
###Output sample 3:
```out
INVALID
```
answer:If there is no answer, please comment
###Input format:
The first line represents the back root sequence of a binary tree, and the second line represents its root sequence. The values of the nodes are all capital letters of A-Z, so the number of nodes in the binary tree is not more than 26, and the two input sequences are guaranteed to be full permutation of nodes, but not necessarily legal middle root and back root sequences.
###Output format:
If the input sequence is illegal (not the middle root sequence and the back root sequence of the same tree), invalid will be output. If the input sequence is legal, the output is two lines. The first line is an integer representing the height of the binary tree, and the second line is a string representing the first root sequence of the binary tree.
###Input sample 1:
```in
CEFDBHGA
CBEDFAGH
```
###Output sample 1:
```out
three
ABCDEFGH
```
###Input sample 2:
```in
CBEDFAGH
CEFDBHGA
```
###Output sample 2:
```out
INVALID
```
###Input sample 3:
```in
BCA
CAB
```
###Output sample 3:
```out
INVALID
```
answer:If there is no answer, please comment