Print all nodes at a distance k

Given a binary tree, a target node in the binary tree, and an integer value k, print all the nodes that are at distance k from the given target node. No parent pointers are available. Print 0 if no such node exist at distance k.
Input Format:
The first line of input will contain an integer n. The next line will contain n integers denoting the the preorder traversal of the BT. The next line will contain n more integers denoting the inorder traversal of the BT. The next line will contain an integer T. Then T lines follow you will be given 2 integers the first one denoting the value of Node and the second one denoting the value of k.

Constraints:
2 ≤ N ≤ 10^3

Output Format
On T lines print space separated desired output for each test case in sorted form

Sample Input
4 60 65 50 70 50 65 60 70 2 60 1 65 2

Sample Output
65 70 70

link
This is the code I wrote and I’m getting 3 wrong and 1 correct.
what is wrong in the code? If something is wrong in my approach please tell me about it