Miswritten DFS
InterviewTime limit1sMemory limit1024 MB
Given a binary tree and a huge K, find the K-th node visited by a buggy pre-order DFS that recurses into the left child twice, without simulating all visits.
Problem
Yunee is working on a data structures assignment. Yunee wrote a function DFS that traverses a binary tree in pre-order. However, Yunee's code recursively called DFS on the left subtree twice, by mistake.
function DFS(node v):
visit v
if v → left exists:
DFS(v → left)
DFS(v → left)
if v → right exists:
DFS(v → right)
The pseudocode of Yunee's DFS is as above. Now consider the following example.

If we pre-order traverse the above tree, the nodes are visited in order. However, Yunee's DFS visits the nodes in order.
Given a binary tree, find the -th node visited by Yunee's DFS. It is guaranteed that is not greater than the total number of visits. The nodes are numbered from to and the root node is always node .
Input
The first line contains two integers and . represents the number of nodes in the tree. is not greater than the total number of visits.
The next lines describe the tree. The -th line contains two integers and . represents the left child of node and represents the right child of node . If there is no corresponding child, is given in place of or .
The root node is always node .
Output
Output the -th node visited by Yunee's DFS.