SP14932 LCA - Lowest Common Ancestor

Description

A tree is an undirected graph in which any two vertices are connected by exactly one simple path. In other words, any connected graph without cycles is a tree. - Wikipedia The lowest common ancestor (LCA) is a concept in graph theory and computer science. Let T be a rooted tree with N nodes. The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of itself). - Wikipedia Your task in this problem is to find the LCA of any two given nodes v and w in a given tree T. ### ![](https://cdn.luogu.com.cn/upload/vjudge_pic/SP14932/0b23f0487b06b8d674d23253a6db517f49ca3acf.png) **For example the LCA of nodes 9 and 12 in this tree is the node number 3.** ### Input The first line of input will be the number of test cases. Each test case will start with a number N the number of nodes in the tree, 1

Input Format

N/A

Output Format

N/A