PROGRAMMING:Interesting recent common ancestor problem
Given the post order traversal and middle order traversal of a binary tree, can you calculate the nearest common ancestor of two nodes?
###Input format:
The first line gives two integers n (n < = 10000) and m (m < = 10000), which represent the number of nodes of the binary tree and the number of queries.
The second line and the third line give n integers respectively, and each integer is separated by a space, which respectively represents the post order traversal and middle order traversal of the binary tree.
Next, line m, each line gives two integers representing the numbers a and B of the two nodes we want to ask.
###Output format:
For each question we ask:
1. If one or two of a and B are not in the tree, output "error".
2. Otherwise, output an integer in a row to represent the nearest common ancestor of a and B.
###Input example:
Here is a set of inputs. For example:
```in
3 3
2 3 1
2 1 3
1 2
2 3
0 3
```
###Output example:
The corresponding output is given here. For example:
```out
one
one
ERROR
```
answer:If there is no answer, please comment
###Input format:
The first line gives two integers n (n < = 10000) and m (m < = 10000), which represent the number of nodes of the binary tree and the number of queries.
The second line and the third line give n integers respectively, and each integer is separated by a space, which respectively represents the post order traversal and middle order traversal of the binary tree.
Next, line m, each line gives two integers representing the numbers a and B of the two nodes we want to ask.
###Output format:
For each question we ask:
1. If one or two of a and B are not in the tree, output "error".
2. Otherwise, output an integer in a row to represent the nearest common ancestor of a and B.
###Input example:
Here is a set of inputs. For example:
```in
3 3
2 3 1
2 1 3
1 2
2 3
0 3
```
###Output example:
The corresponding output is given here. For example:
```out
one
one
ERROR
```
answer:If there is no answer, please comment