For this Question: Given a binary tree of N nodes with root 1. Initially all nodes have value 0.
You have two type of queries
1 u x  - add x to all nodes in subtree of  node u
2 u - print the value of node uFirst 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 queries of two types:
1 u x 
2 x
1 <= N, Q <= 5000
1 <= u <= N
1 <= x <= 5000For each query of type 2 print a single line containing the answerSample Input 1:
9 5
2 4
5 3
6 -1
-1 7
-1 -1
-1 -1
9 8
-1 -1
-1 -1
1 2 5
1 1 3
2 7
1 4 2
2 6
Sample output 1:
3
8

Explanation: Given binary tree 
                1
               /  \
             2     4
            / \     \
          5    3    7
                /    / \
              6     9  8 
Query 1: add all nodes in subtree of 2 with 5
Query 2: add all nodes in subtree of 1 with 3
Query 3: value of node 7 is 3 now
Query 4: add all nodes in subtree of 4 with 2
Query 5: value of node 6 is 8 now, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    Node rootNode;
    static class Node{
        int data;
        Node left,right;
        Node parent;
        Node(int d){
            this.data=d;
        }
    }














    public static void main (String[] args)   throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s[]=br.readLine().split(" ");
        int n=Integer.parseInt(s[0]);
        int q=Integer.parseInt(s[1]);



        Node nodes[]=new Node[n+1];
        for(int i=1;i<=n;i++){
            nodes[i]=new Node(0);
        }
        for(int i=1;i<=n;i++){
            String s1[]=br.readLine().split(" ");
            int x=Integer.parseInt(s1[0]);
            int y=Integer.parseInt(s1[1]);

            if(x!=-1){
                nodes[i].left=nodes[x];
                nodes[x].parent = nodes[i];
            }
            if(y!=-1){
                nodes[i].right=nodes[y];
                nodes[y].parent = nodes[i];
            }

        }
        for(int i=1;i<=q;i++){
            String s2[]=br.readLine().split(" ");
            int type=Integer.parseInt(s2[0]);


            if(type==1){
                int x=Integer.parseInt(s2[1]);
                int y=Integer.parseInt(s2[2]);



                nodes[x].data += y;

            }else{
                int y=Integer.parseInt(s2[1]);


                int value = parentSum(nodes[y]);
                System.out.println(value);
            }
        }
    }
    static int parentSum(Node node)
    {
        if(node.parent == null)
            return node.data;
        return node.data + parentSum(node.parent);
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?