PROGRAMMING:The nearest common ancestor of binary search tree
Given the preorder traversal sequence of a binary search tree, you are required to find the nearest common ancestor node (LCA) of any two nodes.
###Input format:
The first line of input gives two positive integers: the number of nodes to be queried m ($$$Le $$1 000) and the number of nodes in binary search tree n ($$$Le $$10 000). The next line gives n different integers, which is the preorder traversal sequence of binary search tree. Finally, m lines, each line gives a pair of integer key values u and V. All key values are in the range of integer * * int * *.
###Output format:
For each given pair of u and V, if 'a' is the key value of their nearest common ancestor node, output 'LCA of u and V is a.' in one line. However, if one node in U and V is the ancestor of another node, output 'x is an ancestor of Y.' in one line, where 'x' is the key value of that ancestor node and 'y' is another key value. If the node with u or V as the key value cannot be found in the binary search tree, output 'error: u is not found.' or 'error: V is not found.' or 'error: u and V are not found.'.
###Input example:
```in
6 8
6 3 1 2 5 4 8 7
2 5
8 7
1 9
12 -3
0 8
99 99
```
###Output example:
```out
LCA of 2 and 5 is 3.
8 is an ancestor of 7.
ERROR: 9 is not found.
ERROR: 12 and -3 are not found.
ERROR: 0 is not found.
ERROR: 99 and 99 are not found.
```
answer:If there is no answer, please comment
###Input format:
The first line of input gives two positive integers: the number of nodes to be queried m ($$$Le $$1 000) and the number of nodes in binary search tree n ($$$Le $$10 000). The next line gives n different integers, which is the preorder traversal sequence of binary search tree. Finally, m lines, each line gives a pair of integer key values u and V. All key values are in the range of integer * * int * *.
###Output format:
For each given pair of u and V, if 'a' is the key value of their nearest common ancestor node, output 'LCA of u and V is a.' in one line. However, if one node in U and V is the ancestor of another node, output 'x is an ancestor of Y.' in one line, where 'x' is the key value of that ancestor node and 'y' is another key value. If the node with u or V as the key value cannot be found in the binary search tree, output 'error: u is not found.' or 'error: V is not found.' or 'error: u and V are not found.'.
###Input example:
```in
6 8
6 3 1 2 5 4 8 7
2 5
8 7
1 9
12 -3
0 8
99 99
```
###Output example:
```out
LCA of 2 and 5 is 3.
8 is an ancestor of 7.
ERROR: 9 is not found.
ERROR: 12 and -3 are not found.
ERROR: 0 is not found.
ERROR: 99 and 99 are not found.
```
answer:If there is no answer, please comment