//package codeforces;
import java.util.*;
import java.io.*;

public class NearestLeaf {
    public static void main(String[] args) {
        new NearestLeaf().solve();
    }
    
    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);
    int N = 500000, n, q, p;
    int[] w = new int[N]; 
    int[] cot = new int[N];  
    long[] sum = new long[2*N]; 
    long[] delay = new long[N];
    long[] ans = new long[N];
    @SuppressWarnings("unchecked") ArrayList<Integer>[] son = new ArrayList[N];
    @SuppressWarnings("unchecked") ArrayList<triple>[] query = new ArrayList[N];

    class FastReader{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = null;

        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(in.next());
        } 
    }

    class triple{
        int v,l,r;
        triple(int v,int l,int r){
            this.v = v;
            this.l = l;
            this.r = r;
        }
    }

    long min(long x, long y){
        return x<y ? x:y;
    }

    void solve(){
        n = in.nextInt();
        q = in.nextInt();
        for(int i = 0 ; i < n ; i++){
            son[i] = new ArrayList<>();
            query[i] = new ArrayList<>();
        } 
        for(int i = 1 ; i < n ; i++){
            p = in.nextInt()-1;
            w[i] = in.nextInt();
            son[p].add(i);
            sum[n+i] = sum[n+p]+w[i];
        }
        dfs(0);
        for(int i = 0 ; i < n ; i++){
            if(cot[i] > 0){
                sum[n+i] = 1L<<100;
            }
        }    
        for(int i = 0 ; i < q ; i++){
            query[in.nextInt()-1].add(new triple(i,in.nextInt()-1,in.nextInt()-1)); 
        }
        for(int i = n-1 ; i > 0 ; i--){
            sum[i] = min(sum[i<<1], sum[i<<1|1]);
        }
        DFS(0);
        for(int i = 0 ; i < q ; i++){
            out.println(ans[i]);
        }
        out.close();
    }

    void dfs(int u){
        cot[u] += son[u].size();
        for(int i : son[u]){
            dfs(i);
            cot[u] += cot[i];
        }
    }

    void DFS(int u){
        increase(0, n, w[u]);
        increase(u, u+cot[u]+1, -2*w[u]);
        
        for(triple x : query[u]){
            ans[x.v] = query(x.l, x.r+1);
        }
        for(int i : son[u]){
            DFS(i);
        }

        increase(0, n, -w[u]);
        increase(u, u+cot[u]+1, 2*w[u]);
    }

    void increase(int l, int r, long val){
        l += n;
        r += n;
        int ll = l, rr = r;
        while(l < r){
          if((l&1) == 1){
            apply(l++, val);
          }
          if((r&1) ==1 ){
            apply(--r, val);
          }
          l >>= 1;
          r >>= 1;
        }
        update(ll);
        update(rr-1);
    }

    void apply(int i, long val){
        sum[i] += val;
        if(i < n){
            delay[i] += val;
        }
    }

    void update(int i){
        while(i > 1){
            i >>= 1;
            sum[i] = min(sum[i<<1], sum[i<<1|1])+delay[i];
        }
    } 
    
    long query(int l, int r){
        l += n;
        r += n;
        push(l);
        push(r-1);
        long res = 1L<<100;
        while(l < r){
            if((l&1) == 1){
                res = min(res, sum[l++]);
            }
            if((r&1) == 1){
                res = min(res, sum[--r]);
            }
            l >>= 1;
            r >>= 1;
        }
        return res;
    }

    void push(int pos){
        for(int k = (int)(Math.log(n)/Math.log(2)) ; k > 0 ; k--){
        int i = pos>>k;
        if(delay[i] != 0){
            apply(i<<1, delay[i]);
            apply(i<<1|1, delay[i]);
            delay[i] = 0;
        }
      }
    } 
}