Given a Binary Search Tree and 2 nodes value n1 and n2, your task is to find the lowest common ancestor(LCA) of the two nodes .
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains three lines of input.
The first line contains N, the number of nodes of the BST.
The second line contains the values of the nodes, each separated by a space.
The third line contains the two values n1 and n2 separated by a space.
For each testcase, in a new line, print the LCA of n1 and n2.
This is a function problem. You don't have to take any input. You are required to complete the function LCA that takes node, n1, n2 as parameters and returns the node that is LCA of n1 and n2.
1 <= T <= 100
1 <= N <= 100
1 <= Node value <= 1000
5 4 6 3 7 8
The BST in above test case will look like
here the LCA of 7 and 8 is 7 .