PROGRAMMING:Restore binary tree
Given a binary tree traversal and after order traversal, please implement the following two requirements:
(1) Please output the sequence traversal of this binary tree.
(2) Please output the height of this binary tree.
###Input format:
The first line contains an integer n (n < = 1000). The nodes of the binary tree will be numbered from 1 to n.
The second line contains N node numbers, indicating the middle order traversal of the binary tree.
The third line contains N node numbers, indicating the post traversal of the binary tree.
###Output format:
The first line outputs the sequence traversal of binary tree. The node numbers are separated by spaces, and there are no extra spaces at the end.
The second line outputs an integer representing the height of the binary tree.
The title does not guarantee that the input sequence is legal. If it is illegal, please output "error" in one line and exit the program directly.
###Input example:
Here is a set of inputs. For example:
```in
six
6 5 4 3 2 1
5 6 2 3 1 4
```
###Output example:
The corresponding output is given here. For example:
```out
4 6 1 5 3 2
four
```
###Input example:
Here is a set of inputs. For example:
```in
three
2 1 3
3 2 1
```
###Output example:
The corresponding output is given here. For example:
```out
ERROR
```
answer:If there is no answer, please comment
(1) Please output the sequence traversal of this binary tree.
(2) Please output the height of this binary tree.
###Input format:
The first line contains an integer n (n < = 1000). The nodes of the binary tree will be numbered from 1 to n.
The second line contains N node numbers, indicating the middle order traversal of the binary tree.
The third line contains N node numbers, indicating the post traversal of the binary tree.
###Output format:
The first line outputs the sequence traversal of binary tree. The node numbers are separated by spaces, and there are no extra spaces at the end.
The second line outputs an integer representing the height of the binary tree.
The title does not guarantee that the input sequence is legal. If it is illegal, please output "error" in one line and exit the program directly.
###Input example:
Here is a set of inputs. For example:
```in
six
6 5 4 3 2 1
5 6 2 3 1 4
```
###Output example:
The corresponding output is given here. For example:
```out
4 6 1 5 3 2
four
```
###Input example:
Here is a set of inputs. For example:
```in
three
2 1 3
3 2 1
```
###Output example:
The corresponding output is given here. For example:
```out
ERROR
```
answer:If there is no answer, please comment