For this Question: You are given a binary tree rooted at 1. You have to find the mirror image of any node qi about node 1. If it doesn't exist then print -1. Consider the mirror to be a vertical plane at node 1.

Node 1 is considered to be a mirror image of itself.First line contains the integer N and Q, denoting the number of nodes in the binary tree and the number of queries respectively.
Next N lines contains two integers denoting the left and right child of the i-th node respectively. 
If the node doesn't have a left or right child, it is denoted by '-1'
Next Q lines contains a single integer q[i]

Constraints:
1 <= N <= 10^3
1<= Q <= 10^3For each query print in a separate line the mirror image of the node if it exists, otherwise print -1.Sample Input 1:
7 4
2 4
5 3
-1 -1
-1 7
6 -1
-1 -1
-1 -1
2
5
3
1

Sample output 1:
4
7
-1
1

Explanation: Given binary tree 
                1
               /  \
             2     4
            / \      \
          5    3     7
         /
       6
Query 1: mirror image of node 2 is node 4
Query 2: mirror image of node 5 is node 7
Query 3: mirror image of node 3 is the left child of node 4, but since there is no left child, print -1
Query 4: mentioned in statement, I have written this Solution Code: import java.io.*;
import java.util.*;



class Node {
	Node leftChild;
	Node rightChild;
	int data;
	Node() {

	}
	Node(int data) {
		this.data = data;
		this.leftChild = null;
		this.rightChild = null;
	}
}
class Main {
	public static int cal(int number, Node leftPointer, Node rightPointer) {
		if(leftPointer == null || rightPointer == null) {
			return -1;
		}
		if(number == leftPointer.data) {
			return rightPointer.data;
		}
		if(number == rightPointer.data) {
			return leftPointer.data;
		}
		int foundFlag = cal(number, leftPointer.leftChild, rightPointer.rightChild);
		if(foundFlag != -1) {
			return foundFlag;
		}
		return cal(number, leftPointer.rightChild, rightPointer.leftChild);
	}
	public static int mirror(int number, Node root) {
		if((root.leftChild == null && root.rightChild == null) || root.data == number) {
			return 1;
		}
		return cal(number, root.leftChild, root.rightChild);
	}
	public static void main (String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str1[] = br.readLine().split(" ");
		int nodes = Integer.parseInt(str1[0]);
		int queries = Integer.parseInt(str1[1]);
		Map<Integer, Node> map = new HashMap();
		Node root = new Node(1);
		root.leftChild = null;
		root.rightChild = null;
		map.put(1, root);
		for(int j = 1; j <= nodes; j++){
			String str[] = br.readLine().split(" ");
			int leftChild = Integer.parseInt(str[0]);
			int rightChild = Integer.parseInt(str[1]);
			Node leftNode = new Node(leftChild);
			Node rightNode = new Node(rightChild);
			Node parent = map.get(j);
			parent.leftChild = leftChild == -1 ? null : leftNode;
			parent.rightChild = rightChild == -1 ? null : rightNode;

			if(leftChild != -1) {
				map.put(leftChild, leftNode);
			}
			if(rightChild != -1) {
				map.put(rightChild, rightNode);
			}
		}
		for(int i = 0; i < queries; i++) {
			int number = Integer.parseInt(br.readLine());
			System.out.println(mirror(number, root));
		}
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?