You are given a tree representing a company hierarchy. Each employee has a boss (parent), except the CEO (root). Given queries of the form , find the -th boss of employee .
If does not have a -th boss (if exceeds the depth), return . This is the classic -th ancestor problem. Binary lifting solves it perfectly. Build the table once, then answer each query in time.