Kth Ancestor of Tree Node

Given a rooted tree with n nodes and parent pointers, answer multiple queries for the k-th ancestor of a node. Precompute 2^j-th ancestors (binary lifting) for each node to answer each query in O(log n).

Examples
Input: [[-1,0,0,1,1,2,2],[[3,1],[5,2],[6,3]]]
Output: [1,1,-1]
Hints

Kth Ancestor of Tree Node

Given a rooted tree with `n` nodes and parent pointers, answer multiple queries for the k-th ancestor of a node. Precompute 2^j-th ancestors (binary lifting) for each node to answer each query in O(log n).