#include <bits/stdc++.h>
using namespace std;
long long n, q, Head[1000010], Next[1000010], Go[1000010], Fa[1000010],
    Mx[1000010], Len[1000010], Ans[1000010], Cnt = 0;
vector<long long> Son[1000010];
struct node {
  long long l, r, id;
  node() {}
  node(long long _1, long long _2, long long _3) { l = _1, r = _2, id = _3; }
};
vector<node> QL[1000010], QR[1000010];
void addedge(long long x, long long y) {
  Go[++Cnt] = y;
  Next[Cnt] = Head[x];
  Head[x] = Cnt;
}
long long Tg[1000010 * 8], Mn[1000010 * 8];
void pd(long long x) {
  if (Tg[x]) {
    Mn[x * 2] = min((long long)1e18, Mn[x * 2] + Tg[x]);
    Mn[x * 2 + 1] += min((long long)1e18, Mn[x * 2 + 1] + Tg[x]);
    Tg[x * 2] += min((long long)1e18, Tg[x * 2] + Tg[x]);
    Tg[x * 2 + 1] += min((long long)1e18, Tg[x * 2 + 1] + Tg[x]);
    Tg[x] = 0;
  }
}
void add(long long x, long long L, long long R, long long l, long long r,
         long long v) {
  long long md = (L + R) / 2;
  if (L == l && R == r) {
    Tg[x] = min(Tg[x] + v, (long long)1e18);
    Mn[x] = min(Mn[x] + v, (long long)1e18);
    ;
    return;
  }
  pd(x);
  if (l <= md) add(x * 2, L, md, l, min(md, r), v);
  if (r > md) add(x * 2 + 1, md + 1, R, max(md + 1, l), r, v);
  Mn[x] = min(Mn[x * 2], Mn[x * 2 + 1]);
}
long long ask(long long x, long long L, long long R, long long l, long long r) {
  long long md = (L + R) / 2;
  if (L == l && R == r) return Mn[x];
  pd(x);
  long long ans = 1e18;
  if (l <= md) ans = min(ans, ask(x * 2, L, md, l, min(md, r)));
  if (r > md) ans = min(ans, ask(x * 2 + 1, md + 1, R, max(md + 1, l), r));
  return ans;
}
long long tm = 0;
void DFS1(long long x) {
  tm++;
  long long i = x;
  if (Son[x].size())
    add(1, 1, n, i, i, 1e18);
  else
    add(1, 1, n, i, i, -Len[i]);
  for (long long j = 0; j < QL[i].size(); j++) {
    node tmp = QL[i][j];
    long long x = tmp.id, l = tmp.l, r = tmp.r;
    Ans[x] = min(Ans[x], ask(1, 1, n, l, r) + Len[i]);
  }
  for (long long j = 0; j < Son[x].size(); j++) DFS1(Son[x][j]);
  Mx[x] = tm;
  add(1, 1, n, x, tm, 2 * (Len[i] - Len[Fa[i]]));
}
signed main() {
  scanf("%lld%lld", &n, &q);
  memset(Ans, 63, sizeof Ans);
  for (long long i = 2; i <= n; i++) {
    long long p, w;
    scanf("%lld%lld", &p, &w);
    Son[p].push_back(i);
    Fa[i] = p;
    Len[i] = Len[p] + w;
  }
  for (long long i = 1; i <= n; i++) sort(Son[i].begin(), Son[i].end());
  for (long long i = 1; i <= q; i++) {
    long long x, l, r;
    scanf("%lld%lld%lld", &x, &l, &r);
    if (l <= x) QL[x].push_back(node(l, min(r, x), i));
    if (r >= x) QR[x].push_back(node(max(l, x), r, i));
  }
  DFS1(1);
  memset(Tg, 0, sizeof Tg);
  memset(Mn, 0, sizeof Mn);
  for (long long i = n; i >= 1; i--) {
    if (Son[i].size())
      add(1, 1, n, i, i, 1e18);
    else
      add(1, 1, n, i, i, -Len[i]);
    for (long long j = 0; j < QR[i].size(); j++) {
      node tmp = QR[i][j];
      long long x = tmp.id, l = tmp.l, r = tmp.r;
      Ans[x] = min(Ans[x], ask(1, 1, n, l, r) + Len[i]);
    }
    add(1, 1, n, i, Mx[i], 2 * (Len[i] - Len[Fa[i]]));
  }
  for (long long i = 1; i <= q; i++) printf("%lld\n", Ans[i]);
  return 0;
}
