#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define endl '\n'
#define all(a) a.begin(),a.end()
using namespace std;

const int N=5e5+1;
const ll inf=1e18+5;
const int mod=1e9+7;

ll ans[N];
ll ob[N*4];
ll t[N*4];
int id=0;
int max_id[N];
int b[N];
ll d[N];
vector< pair< pair<int,int> ,int> >qq[N];
vector< pair<int,ll> >g[N];
int n;

void push(int v,int l,int r)
{
    if (ob[v]){
        t[v]+=ob[v];
        if (l!=r){
            ob[v+v]+=ob[v];
            ob[v+v+1]+=ob[v];
        }
        ob[v]=0;
    }
}

void update(int v,int l,int r,int l1,int r1,ll x)
{
    push(v,l,r);
    if (l>r1 || r<l1)return;
    if (l>=l1 && r<=r1){
        ob[v]=x;
        push(v,l,r);
        return;
    }
    int mid=(l+r)/2;
    update(v+v,l,mid,l1,r1,x);
    update(v+v+1,mid+1,r,l1,r1,x);
    t[v]=min(t[v+v],t[v+v+1]);
}

ll get(int v,int l,int r,int l1,int r1)
{
    push(v,l,r);
    if (l>r1 || r<l1)return inf;
    if (l>=l1 && r<=r1){
        return t[v];
    }
    int mid=(l+r)/2;
    return min(get(v+v,l,mid,l1,r1),get(v+v+1,mid+1,r,l1,r1));
}

void dfs(int v,int p=-1,int dist=0)
{
    ++id;
    b[v]=id;
    d[v]=dist;
    for (int i=0;i<g[v].size();++i){
        int to=g[v][i].ff;
        int cost=g[v][i].ss;
        if (to==p)continue;
        dfs(to,v,dist+cost);
        max_id[v]=max(max_id[v],max_id[to]);
    }
    max_id[v]=max(max_id[v],b[v]);
}

void upd(int l,int r,int x)
{
    update(1,1,n,l,r,x);
    if (l-1>=1){
        update(1,1,n,1,l-1,-x);
    }
    if (r+1<=n){
        update(1,1,n,r+1,n,-x);
    }
}

void dfs1(int v,int p=-1)
{
    for (int i=0;i<qq[v].size();++i){
        int l,r,num;
        l=qq[v][i].ff.ff;
        r=qq[v][i].ff.ss;
        num=qq[v][i].ss;
        ans[num]=get(1,1,n,l,r);
    }
    for (int i=0;i<g[v].size();++i){
        int to=g[v][i].ff;
        int cost=g[v][i].ss;
        if (to==p)continue;
        int l=b[to];
        int r=max_id[to];
        upd(l,r,-cost);
        dfs1(to,v);
        upd(l,r,cost);
    }
}

main ()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int q;
    cin>>n>>q;
    for (int i=2;i<=n;++i){
        int p,w;
        cin>>p>>w;
        g[p].pb(mp(i,w));
        g[i].pb(mp(p,w));
    }
    for (int i=1;i<=n;++i){
        sort(all(g[i]));
    }
    for (int i=1;i<=q;++i){
        int v,l,r;
        cin>>v>>l>>r;
        qq[v].pb(mp(mp(l,r),i));
    }
    dfs(1);
    update(1,1,n,1,n,inf);
    for (int i=1;i<=n;++i){
        if (max_id[i]==b[i]){
            update(1,1,n,i,i,-inf+d[i]);
        }
    }
    dfs1(1);
    for (int i=1;i<=q;++i){
        cout<<ans[i]<<endl;
    }
}
