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

public class NearestLeaf {

    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);
    int N = (int)5e5+5,h,n,q; 
    long[] t = new long[2*N]; // contains actual segment tree
    long[] d = new long[N]; // contains postpone updates to children
    ArrayList<Integer>[] son = new ArrayList[N];
    int[] w = new int[N]; // w[i] is weight between i and parent of ith node
    int[] ns = new int[N]; // ns[i] is no. of nodes in subtree of node i
    ArrayList<triple>[] query = new ArrayList[N];
    long[] ans = new long[N];

    //set the value at given index
    void apply(int p, long value) {
        t[p] += value;
        if (p < n) d[p] += value;
    }

    // maximum of two elements
    long min(long x,long y){
        return Math.min(x,y);
    }

    // build the initial tree
    void build(){
        for(int i = n-1;i>0;i--)t[i] = min(t[i<<1],t[i<<1|1]);
    }

    // update all parents of child at index p
    void build(int p) {
      while (p > 1) {
            p >>= 1;
            t[p] = min(t[p<<1], t[p<<1|1]) + d[p];
        }
    }
    
    // push all the delayed changes to child at index p
    void push(int p) {
      for (int s = h; s > 0; --s) {
        int i = p >> s;
        if (d[i] != 0) {
          apply(i<<1, d[i]);
          apply(i<<1|1, d[i]);
          d[i] = 0;
        }
      }
    }
    
    // increment a[i] by value (l<=i<r)
    void inc(int l, int r, long value) {
      l += n; r += n;
      int l0 = l, r0 = r;
      for (; l < r; l >>= 1, r >>= 1) {
        if ((l&1)==1) apply(l++, value);
        if ((r&1)==1) apply(--r, value);
      }
      build(l0);
      build(r0 - 1);
    }
    
    // query[l,r)
    long query(int l, int r) {
      l += n; r += n;
      push(l);
      push(r - 1);
      long res = 1L<<62;
      for (; l < r; l >>= 1, r >>= 1) {
        if ((l&1)==1) res = min(res, t[l++]);
        if ((r&1)==1) res = min(t[--r], res);
      }
      return res;
    }

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

    void DFS2(int u){
        inc(0,n,w[u]);
        inc(u,u+ns[u]+1,-2*w[u]);
        
        for(triple x : query[u])ans[x.i] = query(x.l,x.r+1);
        for(int i : son[u])DFS2(i);

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

    void solve(){
        n = in.ni();q = in.ni();h = (int)(Math.log(n)/Math.log(2));
        for(int i=0;i<n;i++){
            son[i] = new ArrayList<>();
            query[i] = new ArrayList<>();
        }
        
        for(int i=1;i<n;i++){
            int par = in.ni()-1;
            son[par].add(i);
            w[i] = in.ni();
            t[i+n] = w[i]+t[par+n];
        }
        DFS(0);

        for(int i=0;i<n;i++)
            if(ns[i]>0)
                t[i+n] = 1L<<60;
        for(int i=0;i<q;i++)
            query[in.ni()-1].add(new triple(i,in.ni()-1,in.ni()-1));
        
        build();

        DFS2(0);
        for(int i=0;i<q;i++)
            out.println(ans[i]);
    }

    

    void run(){
        solve();
        out.close();
    }
    public static void main(String[] args) {
        new NearestLeaf().run();
    }
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        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());}
        long nextLong(){return Long.parseLong(in.next());}
       
        int ni(){return Integer.parseInt(in.next());}
        long nl(){return Long.parseLong(in.next());}
        double nd(){return Double.parseDouble(in.next());}
    }
    class Edges{
        int u,v,w;
        public Edges(int u,int v,int w){
            this.u = u;
            this.v = v;
            this.w = w;
        }
    }
    class triple{
        int i,l,r;
        public triple(int i,int l,int r){
            this.i = i;
            this.l = l;
            this.r = r;
        }
    }
}