#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int n, q;
struct bian {
  int from, to, w;
} eg[N << 1];
int front[N], num;
void add(int x, int y, int w) {
  eg[++num].to = y;
  eg[num].from = front[x];
  front[x] = num;
  eg[num].w = w;
}
long long mins[N << 2], tag[N << 2];
void opt1(int o, int l, int r, int L, int R, long long w) {
  if (L > R) return;
  if (L <= l && r <= R) {
    mins[o] += w;
    tag[o] += w;
    return;
  }
  int mid = (l + r) >> 1;
  if (tag[o]) {
    mins[o << 1] += tag[o];
    mins[o << 1 | 1] += tag[o];
    tag[o << 1] += tag[o];
    tag[o << 1 | 1] += tag[o];
    tag[o] = 0;
  }
  if (mid >= L) opt1(o << 1, l, mid, L, R, w);
  if (mid < R) opt1(o << 1 | 1, mid + 1, r, L, R, w);
  mins[o] = min(mins[o << 1], mins[o << 1 | 1]);
}
long long opt2(int o, int l, int r, int L, int R) {
  if (L > R) return 0;
  if (L <= l && r <= R) return mins[o];
  int mid = (l + r) >> 1;
  if (tag[o]) {
    mins[o << 1] += tag[o];
    mins[o << 1 | 1] += tag[o];
    tag[o << 1] += tag[o];
    tag[o << 1 | 1] += tag[o];
    tag[o] = 0;
  }
  long long re = 1e18;
  if (mid >= L) re = opt2(o << 1, l, mid, L, R);
  if (mid < R) re = min(re, opt2(o << 1 | 1, mid + 1, r, L, R));
  return re;
}
int siz[N];
void dfs1(int o, int from, long long w) {
  int sf = 0;
  siz[o] = 1;
  for (int i = front[o]; i; i = eg[i].from) {
    int to = eg[i].to;
    if (to == from) continue;
    sf = 1;
    dfs1(to, o, w + eg[i].w);
    siz[o] += siz[to];
  }
  if (sf == 0)
    opt1(1, 1, n, o, o, w);
  else
    opt1(1, 1, n, o, o, 1e15);
}
struct qqq {
  int l, r, ids;
};
long long ans[N];
vector<qqq> que[N];
void dfs2(int o, int from) {
  int sf = 0;
  for (int i = 0; i < que[o].size(); ++i)
    ans[que[o][i].ids] = opt2(1, 1, n, que[o][i].l, que[o][i].r);
  for (int i = front[o]; i; i = eg[i].from) {
    int to = eg[i].to;
    if (to == from) continue;
    opt1(1, 1, n, 1, to - 1, eg[i].w);
    opt1(1, 1, n, to, to + siz[to] - 1, -eg[i].w);
    opt1(1, 1, n, to + siz[to], n, eg[i].w);
    dfs2(to, o);
    opt1(1, 1, n, 1, to - 1, -eg[i].w);
    opt1(1, 1, n, to, to + siz[to] - 1, eg[i].w);
    opt1(1, 1, n, to + siz[to], n, -eg[i].w);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, i, y);
  }
  dfs1(1, 0, 0);
  for (int i = 1; i <= q; ++i) {
    int ids, l, r;
    scanf("%d%d%d", &ids, &l, &r);
    que[ids].push_back((qqq){l, r, i});
  }
  dfs2(1, 0);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i] >= 1e15 ? 0 : ans[i]);
}
