#include <bits/stdc++.h>
using namespace std;
const int mn = 1e6 + 5;
const int mod = 1e9 + 7;
int n, q;
struct edge {
  int to, dist;
};
vector<edge> g[mn];
struct query {
  int l, r, id;
};
vector<query> vq[mn];
long long ans[mn];
int n1 = 1;
long long a[mn << 2], b[mn << 2];
int ql, qr;
long long qs;
pair<int, int> rang[mn];
void build(int x, int fa, long long dist) {
  rang[x] = pair<int, int>(x, x);
  if (g[x].empty()) a[n1 + x - 1] = dist;
  for (auto &i : g[x]) {
    build(i.to, x, dist + i.dist);
    rang[x].second = max(rang[x].second, rang[i.to].second);
  }
}
void pushdown(int k) {
  if (b[k]) {
    a[k] += b[k];
    b[k << 1] += b[k];
    b[k << 1 | 1] += b[k];
    b[k] = 0;
  }
}
long long query(int k, int l, int r) {
  if (ql > r || qr < l) return 1e18;
  pushdown(k);
  if (ql <= l && r <= qr)
    return a[k];
  else {
    int mid = l + r >> 1;
    return min(query(k << 1, l, mid), query(k << 1 | 1, mid + 1, r));
  }
}
void upd(int k, int l, int r) {
  if (ql > r || qr < l) return;
  pushdown(k);
  if (ql <= l && r <= qr) {
    b[k] = qs;
    pushdown(k);
  } else {
    int mid = l + r >> 1;
    upd(k << 1, l, mid), upd(k << 1 | 1, mid + 1, r);
    a[k] = min(a[k << 1], a[k << 1 | 1]);
  }
}
void dfs(int x) {
  for (auto &i : vq[x]) {
    ql = i.l, qr = i.r;
    ans[i.id] = query(1, 1, n1);
  }
  for (auto &i : g[x]) {
    ql = 1, qr = n, qs = i.dist;
    upd(1, 1, n1);
    ql = rang[i.to].first, qr = rang[i.to].second, qs = -2 * i.dist;
    upd(1, 1, n1);
    dfs(i.to);
    ql = 1, qr = n, qs = -i.dist;
    upd(1, 1, n1);
    ql = rang[i.to].first, qr = rang[i.to].second, qs = 2 * i.dist;
    upd(1, 1, n1);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int p, w;
    scanf("%d%d", &p, &w);
    g[p].push_back({i + 1, w});
  }
  for (int i = 1; i <= q; i++) {
    int u, l, r;
    scanf("%d%d%d", &u, &l, &r);
    vq[u].push_back({l, r, i});
  }
  while (n1 < n) n1 <<= 1;
  for (int i = 1; i <= n1 * 2; i++) a[i] = 1e18;
  build(1, 0, 0);
  for (int i = n1 - 1; i; i--) a[i] = min(a[i << 1], a[i << 1 | 1]);
  dfs(1);
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
