 #include <bits/stdc++.h>     

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define int ll

using namespace std;

const int maxn = (int)5e5 + 100;
const int mod = (int)1e8 + 7;

#define inf mod

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

int n, q;
vi g[maxn], W[maxn];
vector<pair<pii, int> > Q[maxn];
int t[4 * maxn], lz[4 * maxn];

inline void push(int v, int tl, int tr){
  if(lz[v] == 500000000000005) return;
  t[v] += lz[v];
  if(tl != tr){
    if(lz[v + v + 1] != 500000000000005) lz[v + v + 1] += lz[v];
    else lz[v + v + 1] = lz[v];
    if(lz[v + v] != 500000000000005) lz[v + v] += lz[v];
    else lz[v + v] = lz[v];
  }
  lz[v] = 500000000000005;
}
void upd(int l, int r, int val, int v = 1, int tl = 1, int tr = n){
  push(v, tl, tr);
  if(l > r || l > tr || r < tl){
  	return;
  }
  if(l <= tl && tr <= r){
    if(lz[v] == 500000000000005) lz[v] = val;
    else lz[v] += val;
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) / 2;
  upd(l, r, val, v + v, tl, tm);
  upd(l, r, val, v + v + 1, tm + 1, tr);
  if(t[v + v] >= 0) t[v] = t[v + v];
  if(t[v + v + 1] >= 0) t[v] = min(t[v], t[v + v + 1]);
}
int get(int l, int r, int v = 1, int tl = 1, int tr = n){
  push(v, tl, tr);
  if(l > r || l > tr || r < tl)
    return 500000000000005;
  if(l <= tl && tr <= r){
    if(t[v] < 0) 500000000000005;
    return t[v];
  }
  int tm = (tl + tr) / 2;
  return min(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr)); 
}
int h[maxn], w, ans[maxn], L[maxn], R[maxn];
void calc(int v){
  R[v] = -inf, L[v] = inf;
  if(sz(g[v]) == 0 && v > 1)
    L[v] = v, R[v] = v;
  for(int to : g[v]){
    calc(to);
    L[v] = min(L[v], L[to]);
    R[v] = max(R[v], R[to]);
  }
}
void dfs(int v){
  for(auto x : Q[v]){
    int l = x.f.f, r = x.f.s, pos = x.s;
    if(sz(g[v]) == 0 && v > 1 && l <= v && v <= r) ans[pos] = 0;
    else ans[pos] = get(l, r);
  }
  int it = 0;
  for(int to : g[v]){
    int w = W[v][it++];
    upd(L[to], R[to], -w);
    upd(1, L[to] - 1, w);
    upd(R[to] + 1, n, w);
    dfs(to);
    upd(L[to], R[to], w);
    upd(1, L[to] - 1, -w);
    upd(R[to] + 1, n, -w);
  }
}
main () {
  scanf("%lld%lld", &n, &q);
  forn(i, 2, n){
    int p;
    scanf("%lld%lld", &p, &w);
    g[p].pb(i);
    W[p].pb(w);
    h[i] = h[p] + w;
  }
  forn(v, 1, maxn - 1) t[v] = lz[v] = 500000000000005;
  forn(i, 1, n){
    sort(all(g[i]));
    if(sz(g[i]) == 0 && i > 1){
      upd(i, i, h[i] - 500000000000005);
    }
      
  }
  forn(i, 1, q){
    int v, l, r;
    scanf("%lld%lld%lld", &v, &l, &r);
    Q[v].pb(mp(mp(l, r), i));
  }
  calc(1);
  dfs(1);
  forn(i, 1, q) printf("%I64d\n", ans[i]);
}