#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define ones(x) __builtin_popcount(x)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define dbg(x) cout << (#x) << " = " << x << " "
#define fini cout << "\n";
#define line cout << "-----------------------------------\n";
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
/*
int read (){
    int x = 0, f = 1; char s = getchar();while (s < '0' || s > '9') {if (s == '-') f = -1; s = getchar();}
    while (s >= '0' && s <= '9') x = x * 10 + s - '0', s = getchar();
    return x * f; 
}*/
const int M=5e5+7;
const int N=1e6+7;
const ll inf=2e9;
const int mod=1e9+7;

struct query{
    int l,r,i;
};

int n,q;
set<pll> adj[M];
int cont;
int id[M], leaf[M], sz[M], dis[M];
ll qs[M];
pll t[M<<2];
int lazy[M<<2];
vector<query> Q[M];

pll op(pll a,pll b){
    if (a.ss == 0) return b;
    if (b.ss == 0) return a;
    return min(a, b);
}

void build(int id,int l,int r){
    if (l+1==r){
        t[id] = {dis[l], leaf[l]}; return;
    }

    int m = (l+r)>>1;
    build(id<<1, l, m);
    build(id<<1|1, m, r);
    t[id] = op(t[id<<1], t[id<<1|1]);
}

void push(int id,int l,int r){
    if (l+1<r){
        t[id<<1].ff += lazy[id];
        t[id<<1|1].ff += lazy[id];
        lazy[id<<1] += lazy[id];
        lazy[id<<1|1] += lazy[id];
    }
    lazy[id] = 0;
}

void up(int id,int l,int r,int x,int y,int val){
    if (r<=x || y<=l) return;
    if (x<=l && r<=y){
        t[id].ff += val;
        lazy[id] += val;
        return;
    }

    push(id, l, r);
    int m = (l+r)>>1;
    up(id<<1, l, m, x, y, val);
    up(id<<1|1, m, r, x, y, val);
    t[id] = op(t[id<<1], t[id<<1|1]);
}

pll que(int id,int l,int r,int x,int y){
    if (r<=x || y<=l) return {0, 0};
    if (x<=l && r<=y) return t[id];

    push(id, l, r);
    int m = (l+r)>>1;
    return op(que(id<<1, l, m, x, y), que(id<<1|1, m, r, x, y));
}

void dfs1(int u,int p,ll w){
    id[u] = cont++;
    dis[id[u]] = dis[id[p]] + w;
    sz[u] = 1;
    for (pll v : adj[u])
        if (v.ff != p){
            dfs1(v.ff, u, v.ss);
            sz[u] += sz[v.ff];
        }

    if (sz[u] == 1) leaf[id[u]] = 1;
}

void dfs2(int u,int p){
    for (query x : Q[u]) qs[x.i] = que(1, 0, n, x.l, x.r).ff;

    for (pll v : adj[u])
        if (v.ff != p){
            up(1, 0, n, id[v.ff], id[v.ff] + sz[v.ff], -2*v.ss);
            up(1, 0, n, 0, n, +v.ss);

            dfs2(v.ff, u);

            up(1, 0, n, id[v.ff], id[v.ff] + sz[v.ff], +2*v.ss);
            up(1, 0, n, 0, n, -v.ss);
        }
}

void go(int ide){
    cin >> n >> q;
    fp(i,2,n+1){
        ll v,w; cin >> v >> w;
        adj[i].insert({v, w});
        adj[v].insert({i, w});
    }

    fp(i,0,q){
        int u,l,r; cin >> u >> l >> r; l--;
        Q[u].pb({l, r, i});
    }

    dfs1(1, 1, 0);
    build(1, 0, n);
    dfs2(1, 1);

    fp(i,0,q) cout << qs[i] << "\n";
}

int main(){
    fastio;
    int tst=1;
    // cin >> tst;
    // cout << fixed << setpresicion(12);
    fp(i,0,tst) go(i+1);

    return 0;
}
	 	  	 	   	 	 	     		 	 		