Problem Statement
In a normal tree, the lowest common ancestor (or LCA for short) of two vertices u and v is defined as the lowest vertex that is ancestor of both the vertices.
Given a tree of N vertices, you need to answer in the form "ru v" which means if the root of the tree is at r then what is LCA of u and v.
Input:
The first line contains a single integer N. Each line in the next N - 1 lines contains a pair of integers u and v representing an edge between these two vertices
The next line contains a single integer Q which is the number of the queries. Each line in the next Q lines contains three integers r, u, v representing a query.
Output:
For each query, write out the answer on a single line.
Example:
Input:
4
12
23
CNA - Insight
Aung San Suu
14
2
Sponsored Ad
142
242
D
ELI
Type here to search
write a java program
Answers
Answered by
0
Answer:
sorry but i don`t know the answer
pls mark brainliest
Explanation:
Similar questions