#include <bits/stdc++.h>
using namespace std;
const int DIM = 5e5 + 5;
const long long INF = (1LL << 60);
struct Query {
  int l, r, ps;
  Query(int _l = 0, int _r = 0, int _ps = 0) : l(_l), r(_r), ps(_ps) {}
};
vector<pair<int, int>> edg[DIM];
vector<Query> qry[DIM];
int lef[DIM], rig[DIM], fth[DIM], val[DIM];
long long sgt[DIM << 2], cst[DIM], lzy[DIM], ans[DIM];
void updateLazy(int nd, int le, int ri) {
  if (lzy[nd]) {
    sgt[nd] += lzy[nd];
    if (le != ri) {
      lzy[nd << 1] += lzy[nd];
      lzy[nd << 1 | 1] += lzy[nd];
    }
    lzy[nd] = 0;
  }
}
void build(int nd, int le, int ri) {
  if (le == ri)
    sgt[nd] = cst[le];
  else {
    int md = (le + ri) >> 1;
    build(nd << 1, le, md);
    build(nd << 1 | 1, md + 1, ri);
    sgt[nd] = min(sgt[nd << 1], sgt[nd << 1 | 1]);
  }
}
void update(int nd, int le, int ri, int st, int en, int vl) {
  updateLazy(nd, le, ri);
  if (ri < st or en < le) return;
  if (st <= le and ri <= en) {
    lzy[nd] += vl;
    updateLazy(nd, le, ri);
  } else {
    int md = (le + ri) >> 1;
    update(nd << 1, le, md, st, en, vl);
    update(nd << 1 | 1, md + 1, ri, st, en, vl);
    sgt[nd] = min(sgt[nd << 1], sgt[nd << 1 | 1]);
  }
}
long long query(int nd, int le, int ri, int st, int en) {
  updateLazy(nd, le, ri);
  if (ri < st or en < le) return INF;
  if (st <= le and ri <= en)
    return sgt[nd];
  else {
    int md = (le + ri) >> 1;
    return min(query(nd << 1, le, md, st, en),
               query(nd << 1 | 1, md + 1, ri, st, en));
  }
}
void preDfs(int x, long long v = 0) {
  lef[x] = rig[x] = x;
  cst[x] = v;
  for (pair<int, int> ed : edg[x]) {
    int y = ed.first, c = ed.second;
    if (y != fth[x]) {
      preDfs(y, v + c);
      cst[x] = INF;
      rig[x] = max(rig[x], rig[y]);
    }
  }
}
void dfs(int x, int n) {
  for (Query qr : qry[x]) {
    int l = qr.l, r = qr.r, ps = qr.ps;
    ans[ps] = query(1, 1, n, l, r);
  }
  for (pair<int, int> ed : edg[x]) {
    int y = ed.first, c = ed.second;
    if (y != fth[x]) {
      update(1, 1, n, 1, n, c);
      update(1, 1, n, lef[y], rig[y], -c * 2);
      dfs(y, n);
      update(1, 1, n, 1, n, -c);
      update(1, 1, n, lef[y], rig[y], c * 2);
    }
  }
}
int main(void) {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    scanf("%d %d", &fth[i], &val[i]);
    edg[fth[i]].push_back({i, val[i]});
  }
  for (int i = 1; i <= q; ++i) {
    int x, l, r;
    scanf("%d %d %d", &x, &l, &r);
    qry[x].push_back(Query(l, r, i));
  }
  preDfs(1);
  build(1, 1, n);
  dfs(1, n);
  for (int i = 1; i <= q; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
